我搜索了几个站点,试图找出如何在远程计算机上运行PowerShell脚本 . 我一直在使用以下命令: Invoke-Command -Session $s -FilePath "C:\Temp\test.ps1" 然而我收到一个错误,说该文件没有'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缺失?
下面的两个答案都解决了它找不到脚本的问题,但现在看起来它运行脚本,但本地机器上没有任何反应:
test.ps1脚本具有以下代码: cscript C:\Temp\queryTest.vbs .
queryTest.vbs文件具有以下代码:`
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
`
当我远程运行test.ps1时,没有什么东西写在excel文件中,但是如果我在本地机器上启动它就可以正常运行 . 我试过从powershell调用ps1脚本和vbs脚本 .