Skip to content

4. Special Operators

Note

The below information is extensively based in information taken from the PowerShell® Notes for Professionals book. I plan to extend this information based on my day to day usage of the language.

4.1: Array Expression Operator

Returns the expression as an array.

1
@( Get-ChildItem $env:windir\System32\ntdll.dll)

Will return an array with one item

1
@( Get-ChildItem $env:windir\System32)

Will return an array with all the items in the folder (which is not a change of behavior from the inner expression.

4.2: Call Operation

1
2
$command = 'Get-ChildItem'
& $Command

Will execute Get-ChildItem

4.3: Dot sourcing operator

1
. .\myScript.ps1

runs .\myScript.ps1 in the current scope making any functions and variables available in the current scope.