public:common_patterns_in_powershell
This is an old revision of the document!
Table of Contents
Common patterns in PowerShell
Getting help on a cmdlet
You can use the Get-Help command to get the Powershell alternative of a man page. E.g.:
Get-Help "Test-Path'
The first time you use ''Get-Help', PowerShell may need some time to download necessary help files.
Defining an empty list
You can define an empty list like so:
$a = @()
And you can add items by:
$a += ,$item
Creating custom objects
To more conveniently manage or output data while using Powershell, it is often useful to use custom objects. They can be created as follows:
$Person = [PSCustomObject]@{ FullName = "Thomas De Reyck" Age = 37 Job = "IT technician" }
When you output the created object afterwards, we can see our own custom fields:
> $Person FullName Age Job -------- --- --- Thomas De Reyck 37 IT technician
public/common_patterns_in_powershell.1713358396.txt.gz · Last modified: by thomas
