First, i assign this string variable:
PS> $newpath="C:\Program Files (x86)\Intel\iCLS Client"
This works:
PS> [Environment]::SetEnvironmentVariable('Path', $newpath, 'Machine')
This doesn't:
PS> Start-Process Powershell -ArgumentList "-NoExit -noprofile -noninteractive -command [Environment]::SetEnvironmentVariable('Path', $newpath, 'Machine')" -Wait
The second example returns:
At line:1 char:46
+ [Environment]::SetEnvironmentVariable('Path', C:\Program Files (x86)\Intel\iCLS ...
+ ~
Missing expression after ','.
At line:1 char:47
+ [Environment]::SetEnvironmentVariable('Path', C:\Program Files (x86)\Intel\iCLS ...
+ ~~~~~~~~~~
Unexpected token 'C:\Program' in expression or statement.
At line:1 char:98
+ ... ient, 'Machine')
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingExpressionAfterToken
What am i doing wrong? I'm thinking it has something to do with strings, spaces, or quotes....
thx