database-tools

Removing Empty Things

How do you exclude objects based on empty properties? For example, WMI returns all kinds of "network adapters:" Get-WMIObject...

read more

Filtering Day of Week

You can also use this little helper function if you run scripts every day and want to make sure they don't do anything on weekends: function...

read more

Finding Object Types

When you pipe the result of a command to Get-Member, it examines the returned objects and shows the properties and methods. Use this line if you...

read more

Built-in Methods

Strings contain all the methods you may need to access its content or manipulate it otherwise. Here is how you can list those methods: "Hello" |...

read more

Create HTML System Reports

ConvertTo-HTML is a great way of creating system reports because you can combine information gathered from different sources into one report. The...

read more

Create HTML reports

ConvertTo-HTML will convert text information into simple HTML, which can then be saved to disk. These reports will work fine, even though they are...

read more

Printing Results

You will discover that Out-Printer can print results to your default printer. You can also print to any other printer when you specify its name:...

read more

Examining Object Data

If you need to see all properties a result object provides, you should probably add Select-Object * to it like this: Get-Process -Id $pid |...

read more

Multi-Column Lists

If you need to display a lot of information in as little room as possible, you should use Format-List with -Column: Get-Service | Format-Wide...

read more

Getting IPv4 Addresses

You should use WMI to list all IPv4 addresses assigned to a computer: Get-WMIObject win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled...

read more

Automating Native Commands

You'll discover that some native commands require interactive keystrokes before they work. For example, to format a drive, for security reasons you...

read more

Finding Update History

Whenever Windows installs an update via Windows Update, it will log this in its windowsupdate.log file. PowerShell can then parse this file. You...

read more

Get Assigned IP Addresses

If you've ever wanted to know all IP addresses assigned to a machine, you should use WMI: Get-WMIObject win32_NetworkAdapterConfiguration |...

read more

Creating Range of Letters

PowerShell can easily provide a range of numbers, but creating them is not that easy - unless you convert ascii codes into characters: 65..90 |...

read more

Finding Services

You can use a keyword search with WMI to find a specific service. The next line will get you all services with the keyword "cert" in its...

read more

Use Server-Side Queries

If you'd like to speed up things, you should try to filter server side instead of client side whenever you query information. For example, this...

read more