Powershell

Careful with Arrays

Careful with Arrays With PowerShell you never know whether a cmdlet returns an array or a single object. That’s because PowerShell automatically...

read more

Get Volume IDs (Part 2)

In Windows 10 and better, you can use Get-Volume to get volume IDs and other information about your drives: PS> Get-Volume DriveLetter...

read more

Get Volume IDs (Part 1)

You can query WMI to get a list of your drives volume IDs like so: Get-CimInstance -ClassName Win32_Volume | Select-Object -Property DriveLetter,...

read more

Beware of -match

The -match operator is frequently used in scripts however not everyone seems to understand how it really works. It can be a really dangerous filter...

read more

Avoid Add-Member (Part 3)

In the previous tip we looked at a number of clever alternatives to avoid Add-Member when creating your own new objects. While using hash tables to...

read more

Avoid Add-Member (Part 2)

In the previous tip we looked at creating simple data objects, and it became evident that instead of using Add-Member, you can cast a hash table to...

read more

Avoid Add-Member (Part 1)

Often the cmdlet Add-Member is used to create simple objects like this: $user = New-Object -TypeName psobject | Add-Member -MemberType NoteProperty...

read more

Important Keyboard Shortcuts

Two of the most important keyboard shortcuts in any PowerShell environment – whether console, ISE, or VSCode – are TAB and CTRL+SPACE. TAB triggers...

read more

Outputting Color

Occasionally, PowerShell code is supposed to output warnings and reports, so colors can add more readability to it. Traditionally, PowerShell...

read more