Powershell

Simple Breakpoint

If you want PowerShell to halt your script at some point, you can simply add this line: $host.EnterNestedPrompt() This will suspend execution and...

read more

Locking the Computer

To lock your computer from PowerShell, remember that you can launch applications, including rundll32.exe, which can be used to call methods from...

read more

Use RegEx to Extract Text

With Regular Expressions, you can easily extract matching text. Have a look: $text = 'The problem was discussed in KB552356. Mail feedback to...

read more

Launching Applications

When you launch *.exe-applications with arguments, you may get exceptions because PowerShell may misinterpret the arguments. A better way to do this...

read more

Appending CSV Data

To append a CSV file with new data, first of all make sure the type of data you append is the same type of data already in a file (or else column...

read more

Create CSV without Header

ConvertTo-CSV can create comma separated values (CSV) on the fly but it always adds a new header. To create CSV data without columns, take a look at...

read more

Eliminating Empty Text

If you wanted to exclude results with empty (text) columns, you can filter based on $null values. This will get you all processes with a valid...

read more

Adding Personal Drives

In a previous tip we showed you how you can add new drives to easily access your desktop, your cookies or media like music and video. However, when...

read more

Enumerating Network Cards

In a previous tip you learned how to use a shortcut to quickly open the dialog with your network adapters. Today, you get a piece of code to access...

read more

Find Local Group Members

If you'd like to list all members of local groups, encapsulate net.exe and make it a PowerShell function: function Get-LocalGroupMember{ param(...

read more

Find Local Groups

On Windows 7, net.exe can list all local groups. To use this information with PowerShell, try this simple wrapper: function Get-LocalGroup { net...

read more

Find Local Users

On Windows 7, the easiest way to find local user accounts is to use net.exe. Here is a simple PowerShell wrapper called Get-LocalUser: function...

read more

Monitor Open Files

In a previous tip we introduced the command openfiles which lists and disconnects files that were opened remotely on your machine. Openfiles can...

read more

Finding Open Files

If you'd like to see which files are opened by network users on your machine, there is an internal command for it. All you need are local admin...

read more