簡體   English   中英

使用Powershell在多個機器上遠程運行安裝文件(.exe)

[英]Run an setup file (.exe) on mutiple machines remotely using powershell

我正在嘗試運行一個復制到所有服務器上指定文件夾的exe文件以及一個參數列表。 但是,此操作失敗,沒有任何錯誤,文件復制正常,但是遠程執行安裝失敗。

以下是我正在寫的內容。

請注意,任何幫助將不勝感激。

$servers = Get-Content c:\temp\servers.txt

foreach ($server in $servers){
    "Processing $server"
    Copy-Item -Path "\\$serverA\utility$\Setup.exe" -Destination "\\$server\c$\temp\Setup.exe" -Force

    $copy_complete = Test-Path "\\$server\c$\temp\Setup.exe" 
    if ($copy_complete) {
        "copy successful"
        Invoke-Command -ComputerName $server -ScriptBlock { Start-Process 'c:\temp\Setup.exe'  -ArgumentList '/quiet /noreboot /enable_remote_assistance  /Exclude "Smart Tools agent","Profile Manager WMI Plugin","Personal vDisk"' }
        "$server completed"
    }
    else {
        "Failed copy, retry manually on $server"
    }
}

您可以嘗試使用呼叫運算符(&)

Invoke-Command -ComputerName $server -ScriptBlock {
    $executable='c:\temp\Setup.exe'
    $arguments='/quiet /noreboot /enable_remote_assistance /Exclude "Smart Tools agent","Profile Manager WMI Plugin","Personal vDisk"'
    & $executable $arguments
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM