Windows 8.1 Pro/Enterprise or Server 2012 R2 Both Windows 8.1 and Server 2012 R2 come with a vast number of additional cmdlets, some of which can be...
ps1
Looking Up Cryptic Error Codes
All PowerShell versions Often, WMI and API calls return cryptic numeric error codes. To find out what went wrong, try this little helper function:...
Converting Error Numbers
All PowerShell Versions Error numbers that are returned by Windows API calls often appear as very large negative numbers. To give meaning to these...
Creating HTML Colors
All Versions To convert decimal color values to a hexadecimal representation, like the one used in HTML, try this line: PS>...
Getting Help
PowerShell 3.0 and later Provided you have downloaded PowerShell help via Update-Help, you can create yourself an excellent help topic viewer with...
Break Into Script with PowerShell 5.0
PowerShell 5.0 Preview As you might know, PowerShell 5.0 Preview is available and comes with vast debugging improvements. One is to be able to debug...
Watch Rick Astley Dance and Sing!
All PowerShell Consoles (not PowerShell ISE) Before you try this, you may want to click the icon in the upper left corner of the PowerShell title...
Pinging via IPv4
All PowerShell versions You can use ping.exe just like any other command inside PowerShell scripts. By adding “-4” to the command line,...
Use F1 in PowerShell ISE
PowerShell ISE 3 and later When you have downloaded the PowerShell help files (using Update-Help from an elevated shell), you can use the Get-Help...
Functions Always Beat Cmdlets
All PowerShell versions Functions always have higher rank than cmdlets, so if both are named alike, the function wins. This function would...
Encrypting and Decrypting Files with EFS
All PowerShell versions Provided EFS (Encrypting File System) is enabled on your system, and you are saving files to a NTFS location, then this is...
Use Out-Host instead of More
PowerShell Console Note that any of this will only work in a “real” console. It will not work in the PowerShell ISE. To output data page...
Invoke-Expression is Evil
All PowerShell versions Try and avoid Invoke-Expression in your scripts. This cmdlet takes a string and executes it as if it was a command. In most...
Display Command History in PowerShell Console
All PowerShell Versions In the PowerShell console (not the PowerShell ISE), you can open a list with the last commands you entered, simply by...
Importing and Installing Certificate
All PowerShell versions To programmatically load a certificate from a file and install it in a specific location inside the certificate store, have...
Using Notepad to Print Things
All PowerShell versions To print a text-based file with the Notepad, try using this line (replace the path to the text file with some path that is...
Changing PowerShell Priority
All PowerShell versions Maybe you’d like a PowerShell script to work in the background, for example copy some files, but you do not want the...
Reading In PFX-Certificate
All PowerShell versions When you use Get-PfxCertificate, you can read in PFX certificate files and use the certificate to sign scripts. However, the...
Accessing SQLServer Database
All Versions, SQL Server You are running an SQL Server? Then here is a PowerShell script template you could use to run an SQL query and retrieve the...
Creating Colorful HTML Reports
All PowerShell versions To turn results into colorful custom HTML reports, simply define three script blocks: one that writes the start of the HTML...
Turning Off “FullLanguage” Mode
All PowerShell versions PowerShell can be restricted in many ways. One is to set the language mode from “FullLanguage” to...
Controlling Execution of Executables
All PowerShell versions PowerShell treats executables (files with extension EXE) like any other command. You can, however, make sure that PowerShell...
Faking Object Type
PowerShell 3 and later The internal PowerShell ETS is responsible for converting objects to text. To do this, it looks for a property called...
Using PowerShell Remoting without Domain
PowerShell 3 and later By default, when you enable PowerShell remoting via Enable-PSRemoting, then only Kerberos authentication is enabled. This...