We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
之前实现了 PowerShell 调用阿里云 Cli 创建手动快照并重启实例,现在由于需要时不时地给阿里云服务器上的 Windows 打补丁,之前都是等手动快照创建完成之后再人工打补丁,太麻烦了,所以研究了一下自动化实现该需求的解决方案。
需要先在 PowerShell 中安装 PSWindowsUpdate 这个模块,有了它就可以检查当前的 Windows 系统是否有需要安装的补丁,并且还可以用它来安装补丁,并在安装完成后自动重启 Windows 系统。
PSWindowsUpdate
然后编写下面的 PowerShell 脚本,用来检查当前 Windows 系统是否有需要安装的补丁,如果有则自动安装,并在安装完成后自动重启。
$output = Get-WindowsUpdate | Out-String $updates = ([regex]'KB(\d)+').Matches($output) if ($updates.Count -gt 0) { Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot }
然后把上面的脚本添加到 Windows 的计划任务中,定时执行:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
需求描述
之前实现了 PowerShell 调用阿里云 Cli 创建手动快照并重启实例,现在由于需要时不时地给阿里云服务器上的 Windows 打补丁,之前都是等手动快照创建完成之后再人工打补丁,太麻烦了,所以研究了一下自动化实现该需求的解决方案。
整体流程
需要先在 PowerShell 中安装
PSWindowsUpdate
这个模块,有了它就可以检查当前的 Windows 系统是否有需要安装的补丁,并且还可以用它来安装补丁,并在安装完成后自动重启 Windows 系统。然后编写下面的 PowerShell 脚本,用来检查当前 Windows 系统是否有需要安装的补丁,如果有则自动安装,并在安装完成后自动重启。
然后把上面的脚本添加到 Windows 的计划任务中,定时执行:
The text was updated successfully, but these errors were encountered: