Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Invoke-Command -ScriptBlock Issue w/ Variables Containing Spaces

$
0
0

I have been working on a script that will help automate MS SQL Server installations on remote machines. Everything seems to be working fine until I get to the Invoke-Command -ScriptBlack {... /SQLSYSADMINACCOUNTS=$using:sysAdAcct ...} part. The variable has spaces in it and when it is read in seems to try and add a domain user that stops at the first space. Is there a way to keep the spaces as is so I get beyond this issue?

ex: $sysAdAcct = "fakeDomain\Fake Admin Acct"

I have tried sending /SQLSYSADMINACCOUNTS="$using:sysAdAcct" as well but it seems that when it reads it in it will only get "fakeDomain\Fake" and it cannot find this account because it does not exist. When I look at the summary.txt file it shows the account as "fakeDomain\Fake,Admin,Acct" and will error out later when it tries to find "fakeDomain\Fake". I have tried sending in the variable multiple ways and I have tried searching for a solution but am at a loss.

Please let me know if any additional information is needed and Thanks!


Viewing all articles
Browse latest Browse all 6937

Trending Articles