PowerShell Switch
Aus Wiki-WebPerfect
Version vom 4. Juni 2018, 14:20 Uhr von Admin (Diskussion | Beiträge)
Example of a basic PowerShell Switch
$SwitchName = <Get-...> #Get-Command or something similar Switch ($SwitchName) { "Name 1" {$SwitchNumber = 1; break} #Answer to the Get-Command = "Name 1" "Name 2" {$SwitchNumber = 2; break} #Answer to the Get-Command = "Name 2" } Switch ($SwitchNumber) { 1 {Write-Host "Name 1 is selected, do someting"} 2 {Write-Host "Name 2 is selected, do someting"} }