Results for “PowerShell”
Small, practical examples. Search by task or narrow things down below.
Create a directory if needed
Ensure a directory exists before writing output.
New-Item✓ Tested
Define a function with a typed parameter
Accept a name and return a greeting.
function✓ Tested
Filter items in a pipeline
Keep numbers that meet a condition.
Where-Object✓ Tested
Format a date without locale ambiguity
Parse an ISO date and format it consistently.
date✓ Tested
Handle a terminating error
Catch conversion failures and produce a clear fallback.
try catch✓ Tested
List files by extension
Enumerate regular files and return their names in order.
Get-ChildItem✓ Tested
Parse JSON into an object
Access a named field in a JSON document.
JSON✓ Tested
Pass named parameters from a hashtable
Keep a command’s options together in a reusable object.
splatting✓ Tested
Read a whole text file
Load text as one string instead of one item per line.
Get-Content✓ Tested
Read rows from CSV text
Parse CSV into objects with named properties.
CSV✓ Tested
Replace repeated whitespace
Normalize runs of whitespace to one space.
regex✓ Tested
Select object properties
Create a smaller object with only the fields you need.
Select-Object✓ Tested