Start-Process "Positional parameter cannot be found" error...

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Bob McCoy Bob McCoy 1 year, 4 months ago.

  • Author
    Posts
  • #32297
    Profile photo of Jesper Kristensen
    Jesper Kristensen
    Participant

    Hi Guys.

    I am completely new to Powershell and am working on my first script. Have been watching some Microsoft PS videos and seeking knowledge on forums etc. and now have high hopes of automating a whole bunch of things, to make my IT life easier.

    This script of mine is to install various applications automatically (and silently if possible) on Windows 7 clients. I found numerous posts regarding "possitional parameter error", but I haven't been able to make any of the solutions work in my own script! So now I am trying this. Will be very thankfull for any help.

    My script looks like this:

    *********************
    #VARIABLES

    $Greenshot = 'Greenshot-INSTALLER-1.2.8.12-RELEASE.exe'
    $GreenshotArgList = '/i', '/VERYSILENT', '/NORESTART', '-Wait'
    $Java =
    $Symantec =
    $Adobe =

    #CREDENTIALS
    $username = "xxx"
    $password = "xxx"
    $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

    # **************** PROGRAMS ******************

    #GREENSHOT

    Start-Process -Credential ($credentials) -FilePath "\\server1\msi\New_Machine\$Greenshot" /ArgumentList "$GreenshotArgList"

    *********************
    The plan is to use the same method on Java, SEP client, Adobe Reader etc.

    I tried with numerous different variations of the argument variable etc. The switches used is from Greenshots homepage, so I am confident that tey are correct.
    But I keep getting the error:
    Start-Process : A positional parameter cannot be found that accepts argument '/VERYSILENT /NORESTART -Wait'.

    The line below works and starts up the Greenshot exe file (but ofcourse isn't silent), so I think installing from UNC path is not the problem:
    Start-Process -Credential ($credentials) -FilePath "\\server1\msi\New_Machine\$Greenshot"

    Can anyone help me out, getting the arguments to work?

    Best Regards,
    Jesper

  • #32302
    Profile photo of Matt Bloomfield
    Matt Bloomfield
    Participant

    Start-Process -Credential ($credentials) -FilePath "\\server1\msi\New_Machine\$Greenshot" /ArgumentList "$GreenshotArgList"

    Use -ArgumentList instead of /ArgumentList.

  • #32304
    Profile photo of Jesper Kristensen
    Jesper Kristensen
    Participant

    O M G.
    ...and I even used the dash in the $credentials variable.

    Thanks a lot Matt.

  • #32305
    Profile photo of Bob McCoy
    Bob McCoy
    Participant

    Old habits can be hard to break. Welcome to PowerShell. It's better here.

You must be logged in to reply to this topic.