case

Powershell Switch

Written by  on Juli 16, 2016

Wie geht ein select-case auf der Powershell?

switch ($(hostname))
{
  hosta
  {
    [string]$Config="hostA.example.com"
  }
  hostb
  {
	[string]$Config="hostB.example.com"
  }
  default
  {
    write-output "Script not configured for $(hostname)!"
	exit 1
  }
}

write-output $Config