Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

PowerShell script / Missing Statement Block in Switch

$
0
0

I have the following script to set a system environment variable based on the default gateway of the PC. It works on one PC just fine... When I run it on another PC, I get the error below. Any ideas why it complains on 1 PC and not the other? Both PCs are windows 7.

Error:

Text
Missing statement block in switch statement clause.At C:\Users\jgrundman\Desktop\SetXBranchServer.ps1:10 char:9+ ##.## <<<< .##.## {$BranchServer = "SERVER1"} + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingSwitchStatementClause

Script:

Powershell
#Writes NIC information to $NIC variable$NIC=Get-WmiObjectWin32_NetworkAdapterConfiguration-computername.#Picks out the Default Gateway info from the $NIC variable and writes it to $gateway$gateway=$NIC.DefaultIPGateway#Sets $BranchServer based on the value of $gatewayswitch($gateway){##.##.##.## {$BranchServer = "SERVER1"}##.##.##.## {$BranchServer = "SERVER2"}}#Creates system Environment Variable "BranchServer" with...
<<<< .##.## {$BranchServer = "SERVER1"} + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingSwitchStatementClause

Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>