且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Powershell 调用命令的问题

更新时间:2022-03-22 23:10:46

您需要先在本地复制包.一旦开始远程处理,您将无法再进行 UNC.

You'll need to copy the package locally first. Once you start remoting you can no longer UNC.

目的地可以是服务器/计算机上的任何地方.我使用温度,但随你喜欢.
我也喜欢使用 $env:windir\temp,以防万一.

The destination can be anywhere on the server/computer. I use the temp but it's whatever you like.
Also I like to use $env:windir\temp, just in case.

    Copy-item "\\servershare\File.msi" -conatiner -recurse `
               \\$Computer\c$\windows\temp\

    Invoke-Command -Computername $Computer -credential $cred -ScriptBlock {
        Start-Process -FilePath `
        "c:\windows\system32\msiexec.exe" `
        -ArgumentList "/i `
        \\computer\e$\installer.msi /qn" -Wait
        }

希望能帮到你.