| 1 |
# This is a simple comment |
| 2 |
function Hello($name) { |
| 3 |
Write-host "Hello $name" |
| 4 |
} |
| 5 |
|
| 6 |
function add($left, $right=4) { |
| 7 |
if ($right -ne 4) { |
| 8 |
return $left |
| 9 |
} elseif ($left -eq $null -and $right -eq 2) { |
| 10 |
return 3 |
| 11 |
} else { |
| 12 |
return 2 |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
$number = 1 + 2; |
| 17 |
$number += 3 |
| 18 |
|
| 19 |
Write-Host Hello -name "World" |
| 20 |
|
| 21 |
$an_array = @(1, 2, 3) |
| 22 |
$a_hash = @{"something" = "something else"} |
| 23 |
|
| 24 |
& notepad .\readme.md |
| 25 |
|
| 26 |
$h1 = @{ FirstName = "James"; LastName = "Anderson"; IDNum = 123 } |
| 27 |
$last = "Anderson"; $IDNum = 120 |
| 28 |
$h2 = @{ FirstName = "James"; LastName = $last; IDNum = $IDNum + 3 } |
| 29 |
$h3 = @{ } |
| 30 |
$h4 = @{ 10 = "James"; 20.5 = "Anderson"; $true = 123 } |
| 31 |
|
| 32 |
${Maximum_Count_26} |
| 33 |
${Name with`twhite space and `{punctuation`}} |
| 34 |
${E:\\File.txt} |
| 35 |
|
| 36 |
"C:\Temp\" {mkdir "C:\Temp\"} |
| 37 |
"C:\Temp\" |
| 38 |
|
| 39 |
@" |
| 40 |
This is a here string |
| 41 |
$h1 = @{ FirstName = "James"; LastName = "Anderson"; IDNum = 123 } |
| 42 |
$last = "Anderson"; $IDNum = 120 |
| 43 |
$h2 = @{ FirstName = "James"; LastName = $last; IDNum = $IDNum + 3 } |
| 44 |
$h3 = @{ } |
| 45 |
$h4 = @{ 10 = "James"; 20.5 = "Anderson"; $true = 123 } |
| 46 |
$j = 20 |
| 47 |
|
| 48 |
still string |
| 49 |
$($i = 10) # pipeline gets nothing |
| 50 |
$(($i = 10)) # pipeline gets int 10 |
| 51 |
$($i = 10; $j) # pipeline gets int 20 |
| 52 |
$(($i = 10); $j) # pipeline gets [object[]](10,20) |
| 53 |
$(($i = 10); ++$j) # pipeline gets int 10 |
| 54 |
$(($i = 10); (++$j)) # pipeline gets [object[]](10,22) |
| 55 |
$($i = 10; ++$j) # pipeline gets nothing |
| 56 |
$(2,4,6) # pipeline gets [object[]](2,4,6) |
| 57 |
"@ |
| 58 |
|
| 59 |
@' |
| 60 |
Expressions inside should be recognised as string |
| 61 |
$h1 = @{ FirstName = "James"; LastName = "Anderson"; IDNum = 123 } |
| 62 |
$last = "Anderson"; $IDNum = 120 |
| 63 |
$h2 = @{ FirstName = "James"; LastName = $last; IDNum = $IDNum + 3 } |
| 64 |
$h3 = @{ } |
| 65 |
$h4 = @{ 10 = "James"; 20.5 = "Anderson"; $true = 123 } |
| 66 |
'@ |