powertips

Finding 10 Largest Files

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...

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...

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...

Exchange 2010 Compiled Help

Want to learn about all the new Exchange 2010 cmdlets? You can download the compiled Help file from Microsoft:...

Discovering Impact Level

In a previous tip, you learned how to use $ConfirmPreference to get a warning before a cmdlet actually changes your system. This was based on the...

How ConfirmPreference works

Cmdlet authors can judge how severe the action is a cmdlet takes and choose from Low over Medium to High. You can use the variable...

Hide Error Messages

You may already know that you can suppress error messages with the ErrorAction parameter, which is often a good idea. Take a look at this and then...

Temporary File Name

Thanks to Get-Date, you can easily create unique temporary file names with a timestamp: (Get-Date -format 'yyyy-MM-dd hh-mm-ss') +...

Parameters Correspond to Columns

Many Get-*-Cmdlets, such as Get-EventLog or Get-Process, will output data in columns and support parameters named like these columns. So to filter...

1 84 85 86 87 88 98