database-tools

Converting TABs to Spaces

When you want to publish PowerShell code, you may want to make sure that all TAB characters are converted to one or more spaces to save space....

read more

Using Shared Variables

By default, all variables created in functions are local, so they only exist within that function and all functions that are called from within this...

read more

Catching Errors

In forums, people often get confused with error handling. For example, this code does not call the error handler. Instead, the red PowerShell error...

read more

Analyzing System Restarts

To find out when a system restarted and why, use the below code to extract the relevant information from the System event log: Get-EventLog -LogName...

read more

Use WMI and WQL!

WMI is a great information resource, and Get-WmiObject makes it easy to retrieve WMI instances. First, use -List parameter to find WMI class names....

read more

Convert to Numeric

Whenever PowerShell asks for user input or reads text file content, the results are text strings. If you expect numbers and want to calculate, make...

read more

Create Own Driver Tool

Thanks to Peter Bishop, here's an enhancement to one of our earlier tips. It turns the command line output delivered by driverquery.exe into a...

read more

Ignoring Empty Lines

To read in a text file and skip blank lines, try this: $file = 'c:\sometextfile.txt' Get-Content $file | Where-Object { $_.Trim() -ne...

read more

Creating System Footprints

WMI can retrieve a lot more object instances than you might think. If you submit a parent class, Get-WmiObject returns all instances of all derived...

read more

Retrieve Exchange Rates

If you need up-to-date exchange rates, try loading the rates via XML from the European Central Bank. This sample gets you the latest exchange rates...

read more