- Jun 13, 2000
- 26,392
- 1,780
- 126
I'm trying to run the NET SHARE command in powershell. Basically, I have a bunch of variables set in a script that builds the command. It looks like this:
$hiddenshare = $login + "$"
$share = $drive + ": \" + $volume + "\" + $login
$NSCMD = $hiddenshare + '=' + $share + "/GRANT:'Everyone,Full'"
echo $NSCMD
NET SHARE $NSCMD
I pulled all my variables together into the $NSCMD var so I could echo that and verify it's formatted correctly.
What I end up with is :NET SHARE username$=N:\users\username /GRANT:'Everyone,Full" as the last line....which fails in my Powershell script.
If I type that in directly on the console, it works. If I drop the "/GRANT:'Everyone,Full" flags, it works from the powershell script.
Does anyone see what might be causing it to hang up? I've tried replacing the apostrophies surrounding Everyone,Full with parentheses and that didn't have any affect, but something in that statement needs to be tweaked from the looks of it.
$hiddenshare = $login + "$"
$share = $drive + ": \" + $volume + "\" + $login
$NSCMD = $hiddenshare + '=' + $share + "/GRANT:'Everyone,Full'"
echo $NSCMD
NET SHARE $NSCMD
I pulled all my variables together into the $NSCMD var so I could echo that and verify it's formatted correctly.
What I end up with is :NET SHARE username$=N:\users\username /GRANT:'Everyone,Full" as the last line....which fails in my Powershell script.
If I type that in directly on the console, it works. If I drop the "/GRANT:'Everyone,Full" flags, it works from the powershell script.
Does anyone see what might be causing it to hang up? I've tried replacing the apostrophies surrounding Everyone,Full with parentheses and that didn't have any affect, but something in that statement needs to be tweaked from the looks of it.
