Reputation: 25
I am a student and am very new to PowerShell.
I am trying to get my msi
to download remotely but i keep encountering an error.
A positional parameter cannot be found that accepts argument '\\share\folder\Path to msi'.
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
+ PSComputerName : RemoteDesktopName
Here is my script:
$msi = @(\\share\folder\Path to msi)
Invoke-Command -ComputerName PCname -ScriptBlock {param($msi) Start-Process msiexec.exe /i "\\Path to msi" /qn /passive -Wait
Start-Sleep 5 } -ArgumentList $msi
Could anyone please help me? Any feedback will be greatly appreciated.
Upvotes: 1
Views: 2100
Reputation: 3046
You dont have to make $msi
an array if the only thing you parse is a string of the Path. Also, why would you use "\Path to msi"
inside the Invoke-Command
if you parse $msi
?
Edit: You should probaly parse the arguments to the msiexec.exe
via -Argumentlist
.
Try this:
$msi = "Path to msi"
Invoke-Command -ComputerName PCname -ScriptBlock {param($msi) Start-Process msiexec.exe -Wait -ArgumentList "/I $msi /qn /passive"} -ArgumentList $msi
Upvotes: 1