I have searched several sites to try to figure out how to run a PowerShell script on a remote machine. I have been using the following command:Invoke-Command -Session $s -FilePath "C:\Temp\test.ps1"
however I get an error back saying the file doesn't exist. However I can search the same machine trough powershell and see that in fact it is there. Any suggestions on what I'm missing?
Both of the answers below fixed the problem of it not finding the script, however now it looks like it runs the script, but nothing happens on the local machine:
The test.ps1 script has the following code:
cscript C:\Temp\queryTest.vbs
.
The queryTest.vbs file has this code:
`
sysdate = "1/1/2015"
Dim e
Dim wb
Dim sheet
Set e = CreateObject("EXCEL.APPLICATION")
e.Workbooks.Open("C:\temp\testbook.xlsx")
Set wb = e.ActiveWorkbook
Set Sheet = wb.Sheets("Sheet1")
sheet.Cells(1,1).Value = sysdate
set sheet = nothing
wb.Save
wb.close
Set wb=nothing
e.Quit
Set e = Nothing
`
Nothing is writing in the excel file when i run test.ps1 remotely, however if i kick if off on the local machine it runs fine. I've tried calling both the ps1 script and the vbs script from powershell.