database-tools

Finding Type Accelerators

PowerShell maintains a list of shortcuts for .NET types to make coding more convenient for you. For example, to convert a string to a DateTime type,...

Returning Multiple Values

A PowerShell function can return multiple values. To receive them, simply assign the result to multiple variables: function Get-DateTimeInfo { #...

Negating Variables

Let's assume you have a variable with a negative value, and you'd like to make it a positive value. Here's a simple way: Basically, this...

Finding Unused Drive Letter

Here's a simple way of finding unassigned drive letters: If you just want any unused drive letter, pipe the result to Get-Random. This approach...

Examining Certificates

Here's how you can pick a certificate from your certificate store. This line will return certificates that have "Tobias" in the...

Changing Current Time Zone

In a previous tip you learned how PowerShell can list all available time zone IDs. Today, we show you how to set the time zone using the utility...

Get Time Zone Info

There is a little known utility called tzutil.exe which can both set the current time zone and get all available time zones. Today, let's check...

Analyzing PowerShell Errors

PowerShell logs all errors in $error variable (unless the cmdlet uses -ErrorAction Ignore). $error contains the error records which in turn contain...

Waiting for Service State

Most high-level cmdlets dealing with services have built-in code to wait for state changes. So when you run Restart-Service to restart a service,...