Support Forums

passing argument to start-process that contains commas ???

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.
User avatar
Rodent
Posts: 40
Joined: Mon Apr 06, 2015 8:10 pm

passing argument to start-process that contains commas ???

Postby Rodent » Sun Sep 27, 2015 8:22 pm

Hi,

Hope I can post this type of question here...

I am trying to run a command using start-process with an argument that has commas or question marks in it but am unable to work out how.

This is my code:

Code: Select all

$cmd = $env:comspec
$arg = "/k TakeOwn.exe /F " + """" + $folder + """" + " /A /R /D Y /SKIPSL"
Start-Process $cmd -Args $arg -WindowStyle 'Normal' -Wait
      
$arg = "/k icacls " + $folder + " /grant DOMAIN\" + $folderName + ":(X, RD, RA, WD, AD, GR)"
Start-Process $cmd -Args $arg -WindowStyle 'Normal' -Wait

$arg = "/k net share " + $folderName + "$=" + $folder + " /grant:EVERYONE, FULL"
Start-Process $cmd -Args $arg -WindowStyle 'Normal' -Wait

now the first start-process works fine but the second one doesn't work, the cmd box gives an error: Invalid parameter "domain\username:(X," and the third also fails giving back the help for 'net share'

as you can see the full list of right are cut of after the first comma.

can anyone provide some help with this
Regards
Rodney
User avatar
SAPIEN Support Forums
Posts: 945
Joined: Wed Dec 03, 2014 2:26 pm

passing argument to start-process that contains commas ???

Postby SAPIEN Support Forums » Sun Sep 27, 2015 8:22 pm

This is an automated post. A real person will respond soon.

Thank you for posting, Rodent.

Here are some hints to help you get an accurate and complete answer to your question.

Ask in the best forum:
If you asked in the wrong forum, just copy your question to the right forum.

Anticipate follow-up questions!

Did you remember to include the following?
    1. Product, version and build
    2. 32 or 64 bit product
    3. Operating system, e.g. Windows 7 64 bit.
    4. Attach a screenshot, if applicable
    5. Attach logs, crash reports, etc., in a ZIP file
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***

Return to “Windows PowerShell”

Who is online

Users browsing this forum: No registered users and 1 guest