Need some help to find the problem with the below.
The issue is around the $setup
Start-Process -workingdirectory c:\temp $setup -wait
$storageDir = 'C:\Temp'
$file = '1.1.1.1'
$SpecIP = '192.168.0.87'
$password = ConvertTo-SecureString "Password" -AsPlainText -Force
$user = "User1"
$cred = New-Object System.Management.Automation.PSCredential ($user,$password)
$rsName = 'Responses.txt'
$setup = "$file.exe $rsName"
The following works I hard code the value
Invoke-Command -ComputerName $SpecIP -Credential $cred -ScriptBlock {
param($setup)
Start-Process -workingdirectory c:\temp 1.1.1.1 Responses.txt -wait
} -ArgumentList $setup
Not working the only different is the $setup
Invoke-Command -ComputerName $SpecIP -Credential $cred -ScriptBlock {
param($setup)
Start-Process -workingdirectory c:\temp $setup -wait
} -ArgumentList $setup
Error
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.StartProcessCo mmand + PSComputerName : 192.168.0.87
I found the issue. I needed to add a .\
before the exe name.
$setup = ".\$dirchosen.exe $rsName"
Start-Process powershell -workingdirectory c:\temp "$setup" -wait
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With