The snippet library.
Small, practical examples. Search by task or narrow things down below.
Assign a value to a variable
PowerShell: Assign a value to a variable using PowerShell 7.
PowerShell✓ Tested
Calculate a simple total
PowerShell: Calculate a simple total using PowerShell 7.
PowerShell✓ Tested
Combine conditions with and
PowerShell: Combine conditions with and using PowerShell 7.
PowerShell✓ Tested
Compare a value with a limit
PowerShell: Compare a value with a limit using PowerShell 7.
PowerShell✓ Tested
Count array elements
PowerShell: Count array elements using PowerShell 7.
PowerShell✓ Tested
Create a portable relative path
PowerShell: Create a portable relative path using PowerShell 7.
PowerShell✓ Tested
Create an array of text values
PowerShell: Create an array of text values using PowerShell 7.
PowerShell✓ Tested
Create an object with named properties
PowerShell: Create an object with named properties using PowerShell 7.
PowerShell✓ Tested
Define a function with a parameter
PowerShell: Define a function with a parameter using PowerShell 7.
PowerShell✓ Tested
Filter pipeline values
PowerShell: Filter pipeline values using PowerShell 7.
PowerShell✓ Tested
Handle an expected terminating error
PowerShell: Handle an expected terminating error using PowerShell 7.
PowerShell✓ Tested
Insert a variable into a string
PowerShell: Insert a variable into a string using PowerShell 7.
PowerShell✓ Tested