All Versions When you run native console EXE commands such as robocopy.exe, ipconfig.exe, or similar commands, you can handle errors raised by these...
Powershell
Using WMI Inheritance
All Versions WMI classes are inherited from each other, and that’s something you can take advantage of. Take this line: PS> Get-WmiObject...
Finding Process Owners
All PowerShell versions To find out who owns a particular process and how many instances are running, try this simple piece of code: $ProcessName =...
Parsing DISM Log File
PowerShell 2.0 and later In your Windows folder, you find all kinds of system log files. One is DISM.log which contains information about the...
Setting Active Directory Attributes
ActiveDirectory Module To set AD attributes for a user account, PowerShell uses hash tables. That’s a versatile approach that lets you specify...
Bulk Creating AD Users from Excel Sheets
Module ActiveDirectory To create a large number of new Active Directory users, you can import the user data from a CSV file, for example export an...
Removing AD Group Members
Module ActiveDirectory To remove one or many users from an Active Directory group, try this approach: $user = @() $user += Get-ADUser -Filter { Name...
Steps to Configure PowerShell (Part 3)
All PowerShell versions If you use PowerShell at home or in an environment without central group policy management, here are some additional steps...
Steps to Configure PowerShell (Part 2)
PowerShell 2.0 and later If you use PowerShell at home or in an unmanaged environment, here are some additional steps you should consider to make...
Steps to Configure PowerShell (Part 1)
PowerShell 2.0 and later If you use PowerShell at home or in an unmanaged environment, here are some steps you should consider to make PowerShell...
NULL Values in Arrays
All PowerShell versions Whenever you assign NULL values to array elements, they will count as array elements, but will not be output (after all,...
Randomize Lists of Numbers
All PowerShell versions This line will take a list of numbers and randomize their order: Get-Random -InputObject 1, 2, 3, 5, 8, 13 -Count...
Reading Disks and Partitions
Windows 8.1 / Server 2012 R2 Disk management has been greatly simplified with the many new client and server cmdlets that ship with Windows 8.1 and...
Finding Out Windows Version
All PowerShell Versions Do you own Windows 8.1 Basic, Pro, or Enterprise? Finding out the Windows version is easy. Finding out the exact subtype is...
Join-Path Fails with Nonexistent Drives
All Versions To construct path names from parent folders and files, you may have been using Join-Path. This cmdlet takes care of the correct number...
Using Cmdlets to Manage Virtual Hard Drives
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...
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...
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...
Enabling and Disabling PowerShell Remoting
PowerShell 3 and later If you want to access a computer remotely via PowerShell, then on the destination side (on the computer you want to visit),...