database-tools

Correctly Filtering DateTime

When you use Where-Object to filter information by date or time, this works actually very well--provided you use the correct filtering format. Do...

Some suggestions

Hi, I think it may be useful in SQL Defrag: 1. To see index script when I see the fragmentation of this index. Now I need to use another tool to do...

Using Fully Qualified Names in Remoting

When you try PowerShell Remoting, you may run into connection errors just because your machine name was not fully qualified. Kerberos authentication...

Ensuring Backward Compatibility

Let's assume you have created this function: function Test-Function { param ( [Parameter(Mandatory=$true)] $ServerPath ) "You selected...

Importing Certificates from PFX Files

You can use Get-PfxCertificate to load digital certificates from PFX files, and then use the certificate to sign script files, for example: $pfxpath...

Reading StringExpand Registry Values

When you read a Registry value of type StringExpand, it will always automatically expand any environment variables contained in the text. This...

Mandatory Parameter with a Dialog

Typically, when you mark a function parameter as "mandatory", PowerShell will prompt the user when the user omits the parameter: function...

Using Comma as Decimal Delimiter

You may not be aware of this, but PowerShell uses a different decimal delimiter for input and output - which may cause confusions to script users....

Testing for Valid Date

If you need to test whether some information resembles a valid date format, here is a test function: function Test-Date { param (...

Multiple Assignments in One Line

When you assign something to a variable, you can enclose the expression in braces. This will also output the data. Have a look: $a = Get-Service ($a...

Pinging Computers

There are multiple ways how you can ping computers. Here is a simple approach that uses the traditional ping.exe but can be easily integrated into...

Playing a Sound on Error

To catch a user’s attention, your script can easily play WAV sound files. Here is a simple function: function Play-Alarm { $path =...

Getting DNS IP Address from Host Name

There is a tiny .NET function called GetHostByName() that is vastly useful. It will look up a host name and return its current IP address:...

Reading and Writing NTFS Streams

When a file is stored on a drive with NTFS file system, you can attach data streams to it to store hidden information. Here is a sample that hides...

Launching Any Excel Version

Microsoft Excel is an example of a program that is not easy to launch directly: the path to Excel may be different, depending on Office version and...

Unblocking Download Files

Any file you download from the Internet or receive via email get marked by Windows as potentially unsafe. If the file contains executables or...

Eliminating Empty Results

To exclude results that have empty properties, you can easily use Where-Object. For example, when you run Get-Hotfix, and you only want to see...

Opening Files in ISE Editor

If you'd like to open a script in the ISE editor, one quick way is using the command "ise". For example, to open your profile script...

Block Comment in PowerShell ISE

Beginning in PowerShell 3.0, when you press and hold ALT and then select something, you get a block selection. If you make this selection as narrow...

Finding Logged-On User

There is a helpful console application called quser.exe which will tell you who is logged on to a machine. The executable returns plain text, but...