繁体   English   中英

在 vSphere 中使用 PowerShell 安装 Windows 更新

[英]Use PowerShell to install Windows Updates in vSphere

我有一个 vSphere windows 客户端集群,大约有 100 个我想每周远程自动化 windows 更新。 我在桌面上的文本文件中列出了所有 windows 机器。 我在本地 windows10 机器上运行了 PSWindowsUpdate 模块,命令如下:
Install-Module -Name PSWindowsUpdate 然后成功执行以下脚本以使我的本地计算机运行 windows 更新。

#Import-Module PSWindowsUpdate
#Remove-Item -Path C:\Scripts\status.tx
#Start-Transcript -Path C:\Scripts\status.txt
#$Updates = "Critical Updates", "Security Updates"
#Get-WUInstall -AcceptALL- Verbose -IgnoreReboot -Category $Updates
#Write-Host "Done"
#Stop-Transcript
#Start-Sleep -s 120
#Restart-Computer -Force -Confirm:$false

-- 电脑重启后以 PS 管理员身份运行 #Get-WindowsUpdate

但是,我不是 PowerShell 方面的专家,所以,我不知道在 vSphere 中远程更新 100 个左右 windows 客户端的任务需要额外编写什么脚本。

任何建议将不胜感激。

您可以尝试使用调用命令。 您可以从 DC 创建服务器列表:

$Servers = (Get-ADObject -Filter * -Properties Name,OperatingSystem | Where-Object OperatingSystem -like ' Server ')

并将此列表与这样的循环一起使用

ForEach($_ in $Servers) { Invoke-Command -ScriptBlock {Get-WUInstall -AcceptALL- Verbose -IgnoreReboot -Category $Updates } -ComputerName $_.Name -ErrorAction SilentlyContinue }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM