Powershell

Enum Week: Listing Enumeration Values

This week we are looking at enumerations: what they are, and how you can benefit from them. In the previous tip we explained how PowerShell converts...

Enum Week: Auto-Conversion for Enums

This week we are looking at enumerations: what they are, and how you can benefit from them. When a cmdlet or method requires an enumeration value,...

Working with UTC Times

When working across language boundaries, you might want to use a way to “normalize” date and time, for example for logging. Instead of...

Displaying Message Boxes

PowerShell can access all public .NET classes, so it is (fairly) easy to create a message box: $result = [System.Windows.MessageBox]::Show('Do...

Using a Stopwatch to Profile Scripts

Ever wanted to find out how long a particular command or portion of your script took to complete? Here is a simple Stopwatch object that can help...

Saving PowerShell User Defaults

We are about to enter “Color Week” with plenty of tips how you can choose better colors for the PowerShell ISE editor and the console....

Finding ASCII Codes

Here is an easy way to find the ASCII code for any character you may have scraped from a website, or found in a script that you copied from the...

Enabling Remote Administration

PowerShell 2+ Many older DCOM-based commands require a “Remote Administration Firewall Exception” to access remote systems. This...

Finding Auto Starts

PowerShell 3+ If you’d like to know which programs start automatically on your machine, WMI may help: PS C:\> Get-CimInstance -ClassName...

Replacing CSV File Headers

PowerShell 2+ When you read in CSV data and would like to rename the CSV headers, here is a simple approach: just read in the text line by line, and...

Receiving Input via Pipeline

In the previous tip we illustrated how Convert-Umlaut was able to convert special characters in a string. This becomes even more useful if a...

Using Friendly Robocopy

PowerShell 2+ Robocopy is a tool of choice to copy files, and that does not change with PowerShell. You can, however, use PowerShell to embed...

Beware of Changes to PSModulePath

PowerShell 3+ PowerShell examines the $env:PSModulePath environment variable to find out the locations where it searches for extension modules. A...

The Truth About WinRM

PowerShell 3+ The popular winrm command to manage and configure PowerShell Remoting is really just a batch and a VBS file: PS> Get-Command winrm...

Listening to Music in the Background

PowerShell 3+ In the previous tip we presented to you a “Dancing Rick ASCII”, created by Lee Holmes. Lee uses music stored on his server...

Smuggling In PowerShell Code

PowerShell 2 There is a good reason why Invoke-Expression is considered risky. This cmdlet executes whatever string it gets, and attackers can...

Display Windows

PowerShell 3+ It is fairly easy to use WPF (Windows Presentation Foundation) to create and show simple dialog windows in PowerShell. If you’d...

Add a Clock to PowerShell

PowerShell 2+ Here is a fun example that illustrates how to work with timers. It adds a clock to the title bar of the PowerShell console or the...

Changing Page File Location

PowerShell 2+ To move the Windows page file to a new location, you can use WMI: #requires -Version 2 $args = @{ Name = "D:\pagefile.sys" InitialSize...

1 40 41 42 43 44 104