I have this script in the client computer that try to run a script from the server computer:
try {
$s = New-PSSession -ComputerName "name" -Authentication CredSSP -Credential $credential
Enter-PSSession -Id $s.Id
Set-ExecutionPolicy ByPass -Scope CurrentUser
Invoke-Command -Session $s -FilePath c:\release1.ps1
} catch {
Write-Error "Error occurred: " $_.Exception.ToString()
} finally {
Exit-PSSession
Remove-PSSession $s }
the script in the server is something like this
Set-Alias vmrun "C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe"
Start-Process -NoNewWindow -FilePath vmrun -ArgumentList " -T ws revertToSnapshot M:\myvm.vmx Release1"
but I got the error
Write-Error : A positional parameter cannot be found that accepts argument 'System.Management.Automation.ItemNotFoundException: Cannot find path 'C:\release1.ps1' because it does not exist.
-FilePathmust specify a path to a file on the local computer. IsC:\release1.ps1on the local computer or the remote one?Enter-PSSession -Id $s.Identers an interactive session that the user must explicitly exit. Therefore, all subsequent commands (a) don't execute until that has happened and (b) then execute locally.