"first line`nsecond line"
PS C:\> "first line`nsecond line" first line second line
"first line`nsecond line"
PS C:\> "first line`nsecond line" first line second line
'{0:N}' -f $number
PS C:\> $number = 1234567890 >> '{0:N}' -f $number 1,234,567,890.00
$array = 'The','quick','brown','fox','jumps','over','the','lazy','dog.'
$array -join(';')
PS C:\> $array = 'The','quick','brown','fox','jumps','over','the','lazy','dog.' >> $array -join(';') The;quick;brown;fox;jumps;over;the;lazy;dog.
$array = 'The','quick','brown','fox','jumps','over','the','lazy','dog.'
$array -join(' ')
PS C:\> $array = 'The','quick','brown','fox','jumps','over','the','lazy','dog.' >> $array -join(' ') The quick brown fox jumps over the lazy dog.
$string1 = "The quick brown fox "
$string2 ="jumps over the lazy dog"
$string1 + $string2
PS C:\> $string1 = "The quick brown fox " >> $string2 ="jumps over the lazy dog" >> $string1 + $string2 The quick brown fox jumps over the lazy dog
$string = 'The quick brown {0} jumps over the lazy {1}.'
$string -f 'fox','dog'
PS C:\> $string = 'The quick brown {0} jumps over the lazy {1}.' >> $string -f 'fox','dog' The quick brown fox jumps over the lazy dog.
[datetime]$date = Get-Date
$date.ToString('yyyy-MM-dd')
PS C:\> [datetime]$date = Get-Date >> $date.ToString('yyyy-MM-dd') 2019-03-28
[int]$int = 10
$int.ToString()
PS C:\> [int]$int = 10 >> $int.ToString() 10
[double]$pi = 22/7
$pi.ToString('0.00')
PS C:\> [double]$pi = 22/7 >> $pi.ToString('0.00') 3.14
[int]$int = 7
$int.ToString('000')
PS C:\> [int]$int = 7 >> $int.ToString('000') 007
Get-Alias | Out-String
PS C:\> Get-Alias | Out-String CommandType Name Version Source ----------- ---- ------- ------ Alias % -> ForEach-Object Alias ? -> Where-Object Alias ac -> Add-Content Alias asnp -> Add-PSSnapin Alias cat -> Get-Content Alias cd -> Set-Location Alias CFS -> ConvertFrom-String 3.1.0.0 Microsoft.PowerShell.Utility Alias chdir -> Set-Location Alias clc -> Clear-Content Alias clear -> Clear-Host Alias clhy -> Clear-History Alias cli -> Clear-Item Alias clp -> Clear-ItemProperty Alias cls -> Clear-Host Alias clv -> Clear-Variable Alias cnsn -> Connect-PSSession Alias compare -> Compare-Object Alias copy -> Copy-Item Alias cp -> Copy-Item Alias cpi -> Copy-Item Alias cpp -> Copy-ItemProperty Alias curl -> Invoke-WebRequest Alias cvpa -> Convert-Path Alias dbp -> Disable-PSBreakpoint Alias del -> Remove-Item Alias diff -> Compare-Object Alias dir -> Get-ChildItem Alias dnsn -> Disconnect-PSSession Alias ebp -> Enable-PSBreakpoint Alias echo -> Write-Output Alias epal -> Export-Alias Alias epcsv -> Export-Csv Alias epsn -> Export-PSSession Alias erase -> Remove-Item Alias etsn -> Enter-PSSession Alias exsn -> Exit-PSSession Alias fc -> Format-Custom Alias fhx -> Format-Hex 3.1.0.0 Microsoft.PowerShell.Utility Alias fl -> Format-List Alias foreach -> ForEach-Object Alias ft -> Format-Table Alias fw -> Format-Wide Alias gal -> Get-Alias Alias gbp -> Get-PSBreakpoint Alias gc -> Get-Content Alias gci -> Get-ChildItem Alias gcm -> Get-Command Alias gcs -> Get-PSCallStack Alias gdr -> Get-PSDrive Alias ghy -> Get-History Alias gi -> Get-Item Alias gjb -> Get-Job Alias gl -> Get-Location Alias gm -> Get-Member Alias gmo -> Get-Module Alias gp -> Get-ItemProperty Alias gps -> Get-Process Alias gpv -> Get-ItemPropertyValue Alias group -> Group-Object Alias gsn -> Get-PSSession Alias gsnp -> Get-PSSnapin Alias gsv -> Get-Service Alias gu -> Get-Unique Alias gv -> Get-Variable Alias gwmi -> Get-WmiObject Alias h -> Get-History Alias history -> Get-History Alias icm -> Invoke-Command Alias iex -> Invoke-Expression Alias ihy -> Invoke-History Alias ii -> Invoke-Item Alias ipal -> Import-Alias Alias ipcsv -> Import-Csv Alias ipmo -> Import-Module Alias ipsn -> Import-PSSession Alias irm -> Invoke-RestMethod Alias ise -> powershell_ise.exe Alias iwmi -> Invoke-WMIMethod Alias iwr -> Invoke-WebRequest Alias kill -> Stop-Process Alias lp -> Out-Printer Alias ls -> Get-ChildItem Alias man -> help Alias md -> mkdir Alias measure -> Measure-Object Alias mi -> Move-Item Alias mount -> New-PSDrive Alias move -> Move-Item Alias mp -> Move-ItemProperty Alias mv -> Move-Item Alias nal -> New-Alias Alias ndr -> New-PSDrive Alias ni -> New-Item Alias nmo -> New-Module Alias npssc -> New-PSSessionConfigurationFile Alias nsn -> New-PSSession Alias nv -> New-Variable Alias ogv -> Out-GridView Alias oh -> Out-Host Alias popd -> Pop-Location Alias ps -> Get-Process Alias pushd -> Push-Location Alias pwd -> Get-Location Alias r -> Invoke-History Alias rbp -> Remove-PSBreakpoint Alias rcjb -> Receive-Job Alias rcsn -> Receive-PSSession Alias rd -> Remove-Item Alias rdr -> Remove-PSDrive Alias ren -> Rename-Item Alias ri -> Remove-Item Alias rjb -> Remove-Job Alias rm -> Remove-Item Alias rmdir -> Remove-Item Alias rmo -> Remove-Module Alias rni -> Rename-Item Alias rnp -> Rename-ItemProperty Alias rp -> Remove-ItemProperty Alias rsn -> Remove-PSSession Alias rsnp -> Remove-PSSnapin Alias rujb -> Resume-Job Alias rv -> Remove-Variable Alias rvpa -> Resolve-Path Alias rwmi -> Remove-WMIObject Alias sajb -> Start-Job Alias sal -> Set-Alias Alias saps -> Start-Process Alias sasv -> Start-Service Alias sbp -> Set-PSBreakpoint Alias sc -> Set-Content Alias select -> Select-Object Alias set -> Set-Variable Alias shcm -> Show-Command Alias si -> Set-Item Alias sl -> Set-Location Alias sleep -> Start-Sleep Alias sls -> Select-String Alias sort -> Sort-Object Alias sp -> Set-ItemProperty Alias spjb -> Stop-Job Alias spps -> Stop-Process Alias spsv -> Stop-Service Alias start -> Start-Process Alias sujb -> Suspend-Job Alias sv -> Set-Variable Alias swmi -> Set-WMIInstance Alias tee -> Tee-Object Alias trcm -> Trace-Command Alias type -> Get-Content Alias wget -> Invoke-WebRequest Alias where -> Where-Object Alias wjb -> Wait-Job Alias write -> Write-Output
$animal = 'fox'
'The quick brown $animal jumps over the lazy dog.'
PS C:\> $animal = 'fox' >> 'The quick brown $animal jumps over the lazy dog.' The quick brown $animal jumps over the lazy dog.
$animal = 'FOX'
"The quick brown $($animal.ToLower()) jumps over the lazy dog $(2 + 3) times."
PS C:\> $animal = 'FOX' >> "The quick brown $($animal.ToLower()) jumps over the lazy dog $(2 + 3) times." The quick brown fox jumps over the lazy dog 5 times.
$animal = 'fox'
"The quick brown $animal jumps over the lazy dog."
PS C:\> $animal = 'fox' >> "The quick brown $animal jumps over the lazy dog." The quick brown fox jumps over the lazy dog.
$option = [System.StringSplitOptions]::RemoveEmptyEntries
$string.split(";",$option)
PS C:\> $string = 'A1;B2;;D4' >> $option = [System.StringSplitOptions]::RemoveEmptyEntries >> $string.split(";",$option) A1 B2 D4
$string = "LastName, FirstName ([samaccountname])"
[Regex]::Matches($string, '(?<=\[)(.*?)(?=])').Value
PS C:\> $string = "LastName, FirstName ([samaccountname])" >> [Regex]::Matches($string, '(?<=\[)(.*?)(?=])').Value samaccountname
$string = '"LastName, FirstName" ([samaccountname])'
[Regex]::Matches($string, '(?<=\")(.*?)(?=\")').Value
PS C:\> $string = '"LastName, FirstName" ([samaccountname])' >> [Regex]::Matches($string, '(?<=\")(.*?)(?=\")').Value LastName, FirstName
$string = "LastName, ([samaccountname])"
[Regex]::Matches($string, '(?<=\<)(.*?)(?=\>)').Value
PS C:\> $string = "LastName,([samaccountname])" >> [Regex]::Matches($string, '(?<=\<)(.*?)(?=\>)').Value FirstName
$string = "LastName, FirstName ([samaccountname])"
[Regex]::Matches($string, '(?<=\()(.*?)(?=\))').Value
PS C:\> $string = "LastName, FirstName ([samaccountname])" >> [Regex]::Matches($string, '(?<=\()(.*?)(?=\))').Value [samaccountname]
$string = "'LastName', ([samaccountname])"
[Regex]::Matches($string, "(?<=\')(.*?)(?=\')").Value
PS C:\> $string = "'LastName',([samaccountname])" >> [Regex]::Matches($string, "(?<=\')(.*?)(?=\')").Value LastName
[Regex]::Matches($string, '(((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))').Value
PS C:\> $string = 'There have been solar eclipses on 03/07/1970, 2/26/1979, and 8/21/2017 in the United States.' >> [Regex]::Matches($string, '(((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))').Value 03/07/1970 2/26/1979 8/21/2017
$emailRegex = @"
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
"@
[Regex]::Matches($string, $emailRegex).Value
PS C:\> $string = "My email is [email protected] but please don't spam me" >> $emailRegex = @" >> (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]) >> "@ >> [Regex]::Matches($string, $emailRegex).Value [email protected]
$guidPattern = "(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}"
[Regex]::Matches($string, $guidPattern).Value
PS C:\> $string = 'Find the guid 1d10da0a-88b2-4129-93a1-e4e33edb3cc5 in this string.' >> $guidPattern = "(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}" >> [Regex]::Matches($string, $guidPattern).Value 1d10da0a-88b2-4129-93a1-e4e33edb3cc5
[Regex]::Matches($string, '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)').Value
PS C:\> $string = 'Reply from 8.8.8.8: bytes=32 time=11ms TTL=54' >> [Regex]::Matches($string, '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)').Value 8.8.8.8
[Regex]::Matches($string, '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))').Value
PS C:\> $string = 'Pinging 2001:4860:4860::8888 with 32 bytes of data' >> [Regex]::Matches($string, '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))').Value 2001:4860:4860::
$string = "In mathematics, summation (capital Greek sigma symbol: ∑) is the addition of a sequence of numbers."
$string.ToCharArray() | ForEach-Object{
$char = $_
try{$ascii = [byte][char]$char}
catch{"$char - None ascii character" }
}
PS C:\> ∑ - None ascii character
[Regex]::Matches($string, '-?\d*\.?\d+').Value
PS C:\> $string = 'The first 10 digits of pi are 3.1415926535.' >> [Regex]::Matches($string, '-?\d*\.?\d+').Value 10 3.1415926535
[Regex]::Matches($string, '(?:^|\b)words(?:$|\b)')
PS C:\> $string = 'A passwords should not contain words found in the dictionary.' >> [Regex]::Matches($string, '(?:^|\b)words(?:$|\b)') Groups : {0} Success : True Name : 0 Captures : {0} Index : 31 Length : 5 Value : words
[Regex]::Matches($string, '((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-](.*?)(?=\s))').Value
PS C:\> $string = 'You can find tons more PowerShell examples at https://www.dowst.dev/category/strings/regex/ with new stuff uploaded every day' >> [Regex]::Matches($string, '((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-](.*?)(?=\s))').Value https://www.dowst.dev/category/strings/regex/
[Regex]::Matches($string, '((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}').Value
PS C:\> $string = 'Phone (123) 456-7890 | 123-456-7890' >> [Regex]::Matches($string, '((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}').Value (123) 456-7890 123-456-7890
$string = "1. Computer name:DC-G11-FTW.contoso.com"
$string.Substring($string.IndexOf(":")+1,$string.length-$string.IndexOf(":")-1)
PS C:\> $string = "1. Computer name:DC-G11-FTW.contoso.com" >> $string.Substring($string.IndexOf(":")+1,$string.length-$string.IndexOf(":")-1) DC-G11-FTW.contoso.com
$string = "[email protected]"
$string.Substring(0,$string.IndexOf("@"))
PS C:\> $string = "[email protected]" >> $string.Substring(0,$string.IndexOf("@")) john.doe
$string = @"
"The quick brown fox jumps over the lazy dog" is an English-language pangrama sentence
that contains all of the letters of the alphabet. It is commonly used for touch-typing
practice, testing typewriters and computer keyboards, displaying examples of fonts, and
other applications involving text where the use of all letters in the alphabet is desired.
Owing to its brevity and coherence, it has become widely known.
"@
$string
PS C:\> $string = @" >> "The quick brown fox jumps over the lazy dog" is an English-language pangrama sentence >> that contains all of the letters of the alphabet. It is commonly used for touch-typing >> practice, testing typewriters and computer keyboards, displaying examples of fonts, and >> other applications involving text where the use of all letters in the alphabet is desired. >> Owing to its brevity and coherence, it has become widely known. >> "@ >> $string "The quick brown fox jumps over the lazy dog" is an English-language pangrama sentence that contains all of the letters of the alphabet. It is commonly used for touch-typing practice, testing typewriters and computer keyboards, displaying examples of fonts, and other applications involving text where the use of all letters in the alphabet is desired. Owing to its brevity and coherence, it has become widely known.
You can use this snippet to parse an email address and extract the different components of it. (Tip. It works for UPNs too)
New-Object "System.Net.Mail.MailAddress" -ArgumentList $emailAddress
‘Microsoft Azure <[email protected]>’
PS C:\> $emailAddress = '[email protected]' >> New-Object "System.Net.Mail.MailAddress" -ArgumentList $emailAddress DisplayName User Host Address ----------- ---- ---- ------- mick.jones contoso.com [email protected]
Being married to someone who majored in English has made me extra conscious of my spelling and capitalization. So, for my blog posts, I’ve written a script to help me ensure my titles are properly capitalized. It is not perfect (i.e. it doesn’t do a dictionary lookup), but it follows the basic APA guidelines. I thought I would share it, in case others would find it useful.
# Split the string into individual words
$words = $string.Split()
[System.Collections.Generic.List[PSObject]]$stringArray = @()
For($i = 0; $i -lt $words.Count; $i++){
# Capitalize words of four or more letters, the first word, and the last word
if($words[$i].Length -gt 3 -or $i -eq 0 -or $i -eq ($words.Count - 1)){
# account for hyphen and capitalize words before and after
$words[$i] = @($words[$i].Split('-') | ForEach-Object{
$_.Substring(0,1).ToUpper() + $_.Substring(1,$_.Length-1)
}) -join('-')
}
# and the capitalized string to the array
$stringArray.Add($words[$i])
}
# join the words back together to form your title
$stringArray -join(' ')
PS C:\> $string = 'properly capitalize a title using PowerShell' >> $words = $string.Split() >> [System.Collections.Generic.List[PSObject]]$stringArray = @() >> For($i = 0; $i -lt $words.Count; $i++){ >> # Capitalize words of four or more letters, the first word, and the last word >> if($words[$i].Length -gt 3 -or $i -eq 0 -or $i -eq ($words.Count - 1)){ >> # account for hyphen and capitalize words before and after >> $words[$i] = @($words[$i].Split('-') | ForEach-Object{ >> $_.Substring(0,1).ToUpper() + $_.Substring(1,$_.Length-1) >> }) -join('-') >> } >> # and the capitalized string to the array >> $stringArray.Add($words[$i]) >> } >> $stringArray -join(' ') Properly Capitalize a Title Using PowerShell
This is a quick and easy password/random character generator. It returns random numbers between 33 and 126 and converts the number to the corresponding ASCII character.
$password = [string]::Empty
1..32 | ForEach-Object {
$password += [char]$(33..126 | Get-Random)
}
$string = "1. Computer name:DC-G11-FTW.contoso.com"
[regex]::Replace($string,"[^0-9a-zA-Z]","")
PS C:\> $string = "1. Computer name:DC-G11-FTW.contoso.com" >> [regex]::Replace($string,"[^0-9a-zA-Z]","") 1ComputernameDCG11FTWcontosocom
$string = "1. Computer name:DC-G11-FTW.contoso.com"
[regex]::Replace($string,"[^0-9a-zA-Z ]","")
PS C:\> $string = "1. Computer name:DC-G11-FTW.contoso.com" >> [regex]::Replace($string,"[^0-9a-zA-Z ]","") 1 Computer nameDCG11FTWcontosocom
"ha" * 5
PS C:\> "ha" * 5 hahahahaha
"<$("#" * 5) Repeating character example $("#" * 5)>"
PS C:\> "<$("#" * 5) Repeating character example $("#" * 5)>" <##### Repeating character example #####>
$string = 'The quick brown fox jumps over the lazy dog'
$string.Replace("brown","red")
PS C:\> $string = 'The quick brown fox jumps over the lazy dog' >> $string.Replace("brown","red") The quick red fox jumps over the lazy dog
$string = 'Thank you for calling 555-5757 your order total is $123.32'
$string -Replace "[0-9]","0"
PS C:\> $string = 'Thank you for calling 555-5757 your order total is $123.32' >> $string -Replace "[0-9]","0" Thank you for calling 000-0000 your order total is $000.00
$array = $string.ToCharArray()
[array]::Reverse($array)
-join($array)
PS C:\> $string = "abcde" >> $array = $string.ToCharArray() >> [array]::Reverse($array) >> -join($array) edcba
$string.split("`n")
PS C:\> $string = @" >> Line 1 >> Line 2 >> Line 3 >> "@ >> $string.split("`n") Line 1 Line 2 Line 3
$string.split(";")
PS C:\> $string = 'A1;B2;C3;D4' >> $string.split(";") A1 B2 C3 D4
$string = "The quick brown fox jumps over the lazy dog."
$string.split()
PS C:\> $string = "The quick brown fox jumps over the lazy dog." >> $string.split() The quick brown fox jumps over the lazy dog.
$string.ToLower()
PS C:\> $string = "WILLIAMS" >> $string.ToLower() williams
$string.ToUpper()
PS C:\> $string = "williams" >> $string.ToUpper() WILLIAMS
$string.Substring(0,1).ToUpper() + $string.Substring(1,$string.Length-1).ToLower()
PS C:\> $string = "williams" >> $string.Substring(0,1).ToUpper() + $string.Substring(1,$string.Length-1).ToLower() Williams
$stringBuilder = New-Object System.Text.StringBuilder
for ($i = 0; $i -lt 10; $i++){
$stringBuilder.Append("Line $i`r`n") | Out-Null
}
$stringBuilder.ToString()
PS C:\> $stringBuilder = New-Object System.Text.StringBuilder >> for ($i = 0; $i -lt 10; $i++){ >> $stringBuilder.Append("Line $i`r`n") | Out-Null >> } >> $stringBuilder.ToString() Line 0 Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9