database-tools

Adding and Subtracting Time

There are actually two different ways of manipulating dates and times. Here is the high-level approach to subtract 30 days from today: (Get-Date) -...

read more

Creating Time Spans

A time span represents a time interval, and you can use time spans to subtract or add time to a date. For example, to get the date seven days ago:...

read more

Add Help to Your Functions

You should simply copy and paste the following block comment right above your functions and magically Get-Help works with your functions, too!...

read more

Check for a Battery

If your script needs to know whether your computer has a battery, you can ask WMI. Here is a small function: function Has-Battery {@(Get-WmiObject...

read more

Creating Your own Types

Did you know that you can compile any .NET source code on the fly and use this to create your own types? Here is an example illustrating how to...

read more

Calculating Server Uptime

Have you ever wanted to find out the effective uptime of your PC (or some servers)? The information can be found inside the event log. Here is an...

read more

Getting Installed Updates

PowerShell is great for parsing log files. Here is a function that extracts all installed Windows updates from an internal log file and returns the...

read more

Replace Text in Files

Often, some text will need to be replaced in a text file. That's easy with Get-Content and Set-Content - or not? Get-Content c:somefile.txt |...

read more

Adding Extra Information

Sometimes you may want to tag results returned by a cmdlet with some extra information, such as a reference to some PC name or a timestamp. You can...

read more

Making Objects Read/Write

Whenever you pipe objects through Select-Object, you actually get a copy of the original object. All properties are now readable and writeable, so...

read more

Creating Relative Dates

To create relative dates like "10 days ago," there are two paths. Administrators often add or remove time spans created by New-Timespan:...

read more

Create Remoting Solutions

Whenever you use WMI (Get-WMIObject) to retrieve information, it's a snap to turn a local solution into a remotable solution. You can just add...

read more

How Much RAM Do You Have?

Ever wondered what type of RAM your PC uses and if there is a bank available to add more? Ask WMI! This example also converts the cryptic type codes...

read more