A positional parameter cannot be found that accepts argument '$null'

This topic is resolved

Share
Viewing 1 reply thread
  • Author
    Posts
    • #1555507
      Leonard Hopkins
      Participant
      Post count: 3
      Member Points: 653
      Rank: Level 2

      An associate was trying to deploy software from SCCM but claims it always failed so he asked me if  I could do it with Powershell. Since this is to be done an on a remote machine, I first connect via PSDrive and get Z as the new drive. After that I copy the source files to the remote machine using Z:\ and this all works fine.

      Next I try to run the installation and it all works except it claims my Argument list is null and fails. I can’t seem to find the proper syntax to pass all of the arguments to the installation line.

      A positional parameter cannot be found that accepts argument ‘$null’.
      + CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
      + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

      0
    • #1555511
      Leos Marek
      Moderator
      Post count: 167
      Member Points: 8,544
      Rank: Level 3

      Hello,

      its because of how Invoke-Command works. You can do it like this:

      Use help for full details on Invoke-command.

      Cheers

      0
      • #1555512
        Leonard Hopkins
        Participant
        Post count: 3
        Member Points: 653
        Rank: Level 2

        Thanks for taking the time to help. However, after applying your recommendation, I still get the same error.

        0
        • #1555513
          Leos Marek
          Moderator
          Post count: 167
          Member Points: 8,544
          Rank: Level 3

          Eh, sorry, I messed it up. You are only passing text to the command, so you do not need to do the param/args thing…. The issue is somewhere else, its how you defined the $Setup variable there. Try this.

          This way the command should get executed and all information should be stored in the Setup variable.

           

          0
        • #1555516
          Leonard Hopkins
          Participant
          Post count: 3
          Member Points: 653
          Rank: Level 2

          Thanks again, but this is exactly what I started with before I asked for help here.

          0
        • #1555517
          Leos Marek
          Moderator
          Post count: 167
          Member Points: 8,544
          Rank: Level 3

          I dont understand your issue then ūüôā see attached picture…. you get the error message due to your syntax. If you use the command correctly there is no error and the cmd.exe is running….

          0
        • #1555518
          Leos Marek
          Moderator
          Post count: 167
          Member Points: 8,544
          Rank: Level 3

          Try it like this

          Invoke-Command -Computername localhost -ScriptBlock {$setup = Start-process -FilePath ‘C:\temp\Greenshot-INSTALLER-1.2.10.6-RELEASE.exe’ ` -argumentlist ‘/verysilent /norestart /suppressmsgboxes’ -Wait -PassThru;$setup.exitcode}

          works like a charm for me.

          0
        • #1555519
          Leonard Hopkins
          Participant
          Post count: 3
          Member Points: 653
          Rank: Level 2

          Yes the “$Setup” variable needed to be changed for the whole process and I took out the “Z” drive specification and just user \ (root). I didn’t get an Exitcode of 0 (zero) though. I did find the log file specified in the parameters shown below. I don’t know what “5” means but at least it did run.

          [InstallShield Silent]
          Version=v7.00
          File=Log File
          [ResponseResult]
          ResultCode=-5

          By the way, my installation is running on a remote computer. It looks like you tested yours locally. We need this to run remotely and be successful. Thanks for the help so far.

           

          Attachments:
          You must be logged in to view attached files.
          0
        • #1555522
          Leos Marek
          Moderator
          Post count: 167
          Member Points: 8,544
          Rank: Level 3

          Since you defined the $Setup variable inside the Invoke-command scriptblock, it only exists on the remote session. You have to “ask” for it in the same scriptblock, otherwise the variable is lost once the Invoke-command completes. Like this:

          It is a best practice to create the script block somewhere before the command in your script, for better visibility

          0
        • #1555523
          Leos Marek
          Moderator
          Post count: 167
          Member Points: 8,544
          Rank: Level 3

          And yes, I was testing on a single VM, but since I have used Invoke-Command, its the same like if you would do it on a remote machine. Powershell will use the remoting feature.

          0
        • #1555521
          Leonard Hopkins
          Participant
          Post count: 3
          Member Points: 653
          Rank: Level 2

          I am marking this as resolved thanks to your help, even though the software is getting a failure code on installation. That is beyond the scope of this question. Thanks.

          0
        • #1555524
          Leos Marek
          Moderator
          Post count: 167
          Member Points: 8,544
          Rank: Level 3

          Dont worry about the subject change, the topic evolved ūüôā I am happy to help.

          Have a good day.

          0
Viewing 1 reply thread
  • You must be logged in to reply to this topic.
© 4sysops 2006 - 2020

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account