posts-powershell

Why Invoke-Expression is Evil

Invoke-Expression takes any string and treats it as PowerShell code. This way, you could construct dynamic code, and then execute it....

Accessing Web Page Content

Beginning with PowerShell 3.0, the cmdlet Invoke-WebRequest can download web page content quite easily. This would scrape all links from...

Analyzing svchost Processes

Occasionally, you may see a bunch of processes named "svchost" in your task monitor or Get-Process output. These processes are hosts for Windows...

Identifying Services by ProcessID

Group-Object is a great cmdlet to create lookup tables. If you wanted to identify a Windows service by its process ID, here is a way: $serviceList =...

Creating Real Classes

PowerShell introduces class support in PowerShell 5.0, but you can define your own classes in other PowerShell versions as well. Simply use C# code...

Adding Test Hosts to PowerShell ISE

To quickly open new test hosts inside the PowerShell ISE that ships with PowerShell 3.0 and better, here is a small helper function: #requires...

Defining Default Parameters

PowerShell can define defaults for any parameter, so if you wanted to always submit a default value for Get-ChildItem‘s –Path parameter,...