The Null-Coalescing Operator

Today we take a closer look at the null-coalescing operator and how it can help us in writing smarter, more concise scripts. PS> $userDate ?? (Get-Date -Format "yyyy-MM-dd") 2021-02-14 PS> $userDate = Get-Date -Year 2020 -Format "yyyy-MM-dd" PS> $userDate ?? (Get-Date -Format "yyyy-MM-dd") 2020-02-14 How it works We can write some simple code to visualize what the null-coalescing operator is doing function nullCoalescingOperator ($leftValue, $rightValue) { if ($null -eq $leftValue) { return $rightValue } else { return $leftValue } } Usually we will want to assign the resulting value to a variable....

2021-03-22 · 2 min · Marco Kamner

Filter Arrays

Filter arrays in PowerShell

2021-02-27 · 1 min · Marco Kamner

Show vCenter On VM Object

Show vCenter on VMs in PowerCLI with this custom property

2021-01-01 · 1 min · Marco Kamner


Script to analyze your PowerShell history

2020-11-15 · 1 min · Marco Kamner

Netstat With Process Names

How to show process names in netstat on Windows

2020-11-09 · 1 min · Marco Kamner

Diff Objects

Diff different data types in PowerShell

2020-11-09 · 1 min · Marco Kamner