2017-08-15 84 views
1

我想通過PowerShell安裝某些Windows更新,因爲我需要修補的計算機數量。通過Powershell推送Windows更新

我使用以下語法;

enter-pssession PCname-PC 

一旦會話連接,我使用以下;

wusa.exe c:\temp\update.msu /quiet /norestart /log:C:\wusa.log 

手頭的問題是沒有任何反應,我每次都收到拒絕訪問。 Powershell作爲管理員運行,本地計算機用戶是管理員。我曾嘗試運行一個腳本,允許會話以域管理員身份進行連接,並獲得相同的結果。

任何幫助在這個問題將不勝感激。謝謝

+0

或者你可以試試這個:$ PC =「PC 「[wmiclass]」\\ $ pc \ root \ cimv2「$ comm =」cmd/c wusa.exe c:\ temp \ update.msu/quiet/norestart /log:C:\wusa.log「 :Win32_Process「)。create($ comm)' – Vitaly

+0

或者你可以嘗試使用credentional參數:'Enter-PSSession -ComputerName PC1 -Credential contoso \ administrator' – Vitaly

+0

S Windows版本阻止您寫入C:\驅動器的根目錄。嘗試更改/登錄到另一個目錄。 –

回答

0

該解決方案最終會複製更新每臺PC:

$PCs = @() 
$Cred = Get-Credential 

ForEach ($PC in $PCs) 
{ 
    $Session = New-PSSession -ComputerName $PC -Credential $Cred 
    Copy-Item -Path 'C:\Temp\Update.msu' -Destination 'C:\Temp\Update.msu' -ToSession $Session -Force 
    Enter-PSSession $Session 
    & wusa C:\Temp\Update.msu /quiet /norestart /log:C:\Temp\wusa.evtx 
    Exit-PSSession 
    Remove-PSSession $Session 
} 

最後一個音符:在事件查看器格式WUSA日誌(.evtx

+0

問題是wusa.exe不能在遠程會話中運行。拒絕訪問不是文件,而是Windows Update API .... – BenH