Beginning Programming With Powershell Cheat Sheet

ADVERTISEMENT

Beginning Programming with Powershell
Cheat Sheet
Variables:
$a
Variable
$a=5
Variable with value
[Int]$a
Typed variable
$a | gm
Determine variable type
$a + $b
Add int variables, or concatenate strings
‘$a’
Returns the literal string “$a”
“$a”
Returns the value held in $a
Pipes and operators:
Dir | gm
Passes the actual directory objects to the “get-member” function
Where-Object{}
Filtering loop operator
?{}
Filtering loop operator (same as Where-Object{})
ForEach-Object{}
Loop operator
%{}
Loop operator (same as ForEach-Object{})
$_
Current object in the pipeline
$_.Name
The name of the current object in the pipeline
-eq
“Equals” comparison operator
-gt
“Greater than” comparison operator
-lt
“Less than” comparison operator
If () {}
If/then operator.
ELSE {}
Try {}
Catch {}
Cmdlets:
Get-Help
Alias help
Where-Object
Alias ?
ForEach-Object
Alias %
Get-Member
Alias gm
Get-Service
Get-Process
Get-ChildItem
Alias dir, also gci
Out-File
Format-Table
Alias ft
Format-List
Alias fl
Test-Path

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 2