Good Afternoon,

I am trying to write a script to install software. The script is below:

$ComputerName = Read-Host -Prompt "Please Enter The Computer Name"
$Software = Read-Host -Prompt "Please Enter The Software Name"
switch ($Software)
    Java {$Software = "C:\Script\Java.msi"}
    Atom {$Software = "C:\Script\AtomSetup.exe"}
    Notepad {$Software = "C:\Script\notepad.exe"}
    Default {Throw No Software Match found for $software}
$session = New-PSSession -ComputerName $ComputerName
Copy-Item -Path $Software -Destination C:\Script -Recurse -Verbose -ToSession $session
$session | Remove-PSSession
Invoke-Command -ComputerName $ComputerName -Credential (Get-Credential) -ScriptBlock {start-process -Filepath $software -ArgumentList '/silent' -wait 
Remove-Item -Path $software -Force

I am getting the error message below.

Cannot validate argument on parameter 'FilePath'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. + CategoryInfo : InvalidData: (:) [Start-Process], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.StartProcessCommand + PSComputerName : testPC

Cannot bind argument to parameter 'Path' because it is null. + CategoryInfo : InvalidData: (:) [Remove-Item], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.RemoveItemCommand + PSComputerName : testPC

Any help would be appreciated


1 Answer 1


Read and follow Invoke-Command docs:


Supplies the values of local variables in the command. The variables in the command are replaced by these values before the command is run on the remote computer. Enter the values in a comma-separated list. Values are associated with variables in the order that they are listed. The alias for ArgumentList is Args.

The values in the ArgumentList parameter can be actual values, such as 1024, or they can be references to local variables, such as $max.

To use local variables in a command, use the following command format:

{param($<name1>[, $<name2>]...) <command-with-local-variables>} -ArgumentList <value> -or- <local-variable>

The param keyword lists the local variables that are used in the command. ArgumentList supplies the values of the variables, in the order that they are listed.


Invoke-Command -ComputerName $ComputerName -Credential (Get-Credential) `
    -ScriptBlock {
        Start-Process -Filepath $software -ArgumentList '/silent' -wait 
        Remove-Item -Path $software -Force
    } -ArgumentList $Software
  • i did like you instructed. I am receiving this error message. This command cannot be run due to the error: The system cannot find the file specified. + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand + PSComputerName : testPC
    – JeffB
    Sep 23, 2019 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.