Powershell

Finding Type Definitions

PowerShell enhances many .NET types and adds additional information. These changes are defined in xml files. To list all .NET types that get...

read more

Analyze Cmdlet Results

There are two great ways to analyze the results a cmdlet returns: you can send the results to Get-Member to get a formal analysis, telling you the...

read more

Listing Process Owners

In a previous tip, you learned that there is a hidden host process named wsmprovhost.exe whenever someone else visits your computer using PowerShell...

read more

Detecting Remote Visitors

Whenever someone connects to your computer using PowerShell remoting, there is a host process called wsmprovhost.exe. You can only see processes...

read more

Make Sure Folder Exists

To ensure that a given folder exists, you can stick to trial-and-error, and hide error messages: New-Item c:\somefolder\anotherfolder\yetanother...

read more

List NTFS Permissions

To view NTFS permissions for folders or files, use Get-Acl. It won't show you the actual permissions at first, but you can make them visible...

read more

Duplicate Output

Sometimes, you may want to store command results in a variable and at the same time, output it to the console. Once you assign results to a...

read more

Set Clipboard

If you are using Windows Vista or better, you can pipe text to clip.exe  to copy it to your clipboard: Dir $env:windir | clip   Here is...

read more

Get-Clipboard

If your PowerShell host uses the STA mode, you can easily read clipboard content like this: function Get-Clipboard { if...

read more

Test for STA mode

By default, the PowerShell console does not use the STA mode whereas the ISE editor does. STA is needed to run Windows Presentation Foundation...

read more

Multiple Text Replace

Imagine that you need to replace a number of different characters in a text. For example, you need to remove special characters or escape something....

read more

Switch Accepts Arrays

Did you know that the Switch statement can accept arrays? Use this sample to translate numbers into words: PS> switch ( 1,5,2,4,3,1 ) { 1 {...

read more

Tile Windows

Do you remember the ancient feature where you could tile or cascade all open windows? These features are still available. However, before you try...

read more