Tutorial by Examples

String Strings are created by wrapping the text with double quotes. Double-quoted strings can evalute variables and special characters. $myString = "Some basic text" $mySecondString = "String with a $variable" To use a double quote inside a string it needs to be escaped usi...
$hash = @{ city = 'Berlin' } $result = 'You should really visit {0}' -f $hash.city Write-Host $result #prints "You should really visit Berlin" Format strings can be used with the -f operator or the static [String]::Format(string format, args) .NET method.
There are multiple ways to create a multiline string in PowerShell: You can use the special characters for carriage return and/or newline manually or use the NewLine-environment variable to insert the systems "newline" value) "Hello`r`nWorld" "Hello{0}World" -f [...
Here-strings are very useful when creating multiline strings. One of the biggest benefits compared to other multiline strings are that you can use quotes without having to escape them using a backtick. Here-string Here-strings begin with @" and a linebreak and end with "@ on it's own lin...
Using variables in a string You can concatenate strings using variables inside a double-quoted string. This does not work with properties. $string1 = "Power" $string2 = "Shell" "Greetings from $string1$string2" Using the + operator You can also join strings usin...
When used inside a double-quoted string, the escape character (backtick `) reperesents a special character. `0 #Null `a #Alert/Beep `b #Backspace `f #Form feed (used for printer output) `n #New line `r #Carriage return `t #Horizontal tab `v #Vertical tab (used for pri...

Page 1 of 1