Reputation: 11
I'm new to Powershell so I'll try my best to describe what i am doing. I'm trying to run a script that will clean out my WSUS server.
this is the part of the code where it gets stuck.
$Adamj `ServerAdminProxy = $Script:WSUSAdminProxy
The error returned
At line:1 char:8 + $Adamj ServerAdminProxy = $Script:WSUSAdminProxy + ~~~~~~~~~~~~~~~~ Unexpected token 'ServerAdminProxy' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken
I though it may have had something to do with the ` to be honest I'm not sure.
Hope this is clear for you..
Upvotes: 1
Views: 9882
Reputation: 547
` is the escape character. Anything directly after it will be treated as is. So `ServerAdminProxy is being treated as additional input or maybe a function call.
Also with the $Script:WSUSAdminProxy, the : will cause the $Script to be treated as a directory aka D:
I'm not sure how you are storing the values you want to retrieve, but you should probably stay away from special characters like ` : \ ' " in your variable names and stick to alphanumeric characters and underscore (_)
Upvotes: 0
Reputation: 59020
To create or display a variable name that includes spaces or special characters, enclose the variable name in braces. This directs PowerShell to interpret the characters in the variable name literally.
Ex:
${save`items} = "a", "b", "c"
Upvotes: 1