You may need to find the largest files for possible clean-up when free space on a drive runs low. One way is to have PowerShell examine all file...
Powershell
Random Tip of the Day
Get-Random has a dual purpose. It can provide you with a random number and also pick random elements from a collection. So, if you want to get a new...
Sorting Stuff
You can use Sort-Object to sort simple variable types. Have a look at the following: 'Tom', 'Chris', 'Judy', 'Alan'...
Finding Invalid Aliases
When you create new Aliases with Set-Alias, PowerShell does not check whether the target you specify is valid. Instead, this is checked only when...
IPv4 Address Lists
You should try this to get all IPv4 addresses assigned to your system: Get-WMIObject win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled...
Getting Assigned IP Addresses
You should use this to retrieve all IP addresses assigned to your computer: Get-WMIObject win32_NetworkAdapterConfiguration | Where-Object...
Generate PC Lists
One easy way of creating lists of PC names or IP address ranges etc is a simple pipeline like this: 1..40 | Foreach-Object {...
Create HTA Files
Another way is to ConvertTo-HTML is a convenient way of converting object results in HTML. However when you open these files, your browser starts...
WMI Server Side Filtering
Whenever you use Get-WMIObject, be sure to minimize resources and maximize speed by using server-side filtering. The next line will use the slow...
List Installed Updates
Using Get-Hotfix is pretty convenient as it serves to list installed updates. Unfortunately, it is not very thorough as it doesn’t retrieve...
Downloading Files Silently in the Background
When using the additional cmdlets in the BitsTransfer module that comes with Windows 7 and Server 2008 R2, you can make downloads happen silently in...
Download Files from the Internet
Windows 7 and Server 2008 R2 come with a module called BitsTransfer, which allows you to access the background intelligent transfer service used by...
Adding New Snapins and Modules
Snapins and modules can add new cmdlets and/or providers to PowerShell. Use this if you would like to see the list of available Snapins:...
Test whether Registry Value exists
You should remember that registry values are treated like properties to a registry key so they have no specific path and you cannot use Test-Path to...
Test whether Registry Key exists
If you would like to test whether a certain registry key exists, you should remember that all registry keys are treated like folders on a drive, so...
Creating Constant Functions
In PowerShell, functions can be constant to prevent them from being deleted anymore, which is necessary if you must protect security-critical...
Adding Protection to Functions
Functions that you define are read/write and can easily be overwritten. You can set the read-only attribute to make a function read-only so that you...
Reading Default Values
Each registry key has a default value. It is called (default) when you look into regedit. To read this default value, you can just use this name...
List Installed Software
Get-ItemProperty reads registry values. You can create a software inventory in just one line since it supports wildcards: Get-ItemProperty...
Read Registry Values
You will find that reading Registry values is not always easy because the Registry is accessible only via the generic "drive" paradigm....
Resolve Paths Gets Lists of Paths
You can use Resolve-Path to support wildcards so you can use it to easily put together a list of file names like this: Resolve-Path...
Adding New Virtual Drives
You do not need to use drive letters to access information provided by PowerShell providers. For example, you should use this to list the...
ExpandProperty to the Rescue
You will find that Select-Object is often used to select object properties and discard unneeded information: Get-Process | Select-Object Name,...
Open Explorer
While the PowerShell console is great, it is sometimes just easier to switch to Windows Explorer. Here is the fastest way to open Explorer and show...