This is a draft cheat sheet. It is a work in progress and is not finished yet.
Variables
$var = "string" |
Assign |
$a,$b = 0 |
Assign Multiple |
$a,$b = 0,"string" |
Assign Multiple |
$a,$b = $b,$a |
Flip |
$var = [int]5 |
Strong Type |
|
|
Flow Control
If ( test ) { } Elseif ( test2 ) { } else { } |
while ( test ) { } |
For($i = 0; $i -lt 10; $i ++) { } |
Foreach ($var in $iterable) { use $var here } |
99 .. 1 | foreach { use $_ } |
|
|
Comparisons and Logic
-eq / -ne |
== / != |
-gt / -ge |
> / >= |
-lt / -le |
< / <= |
-match, -notmatch |
regex matching |
-like, -notlike |
wildcard matching |
-contains, -notcontains |
does $left (not) contain $right |
-in, -notin |
is $left (not) in $right |
|