最近要针对一些特定的计算机安装特定的补丁,由于量大且变化快,所以手动管理是不可能了。
由于计算机账号所在的OU有很多组策略,因此根据AD OU结合WSUS方案也被否决了。
作为管理员,对PowerShell已经有所研究:AD,Exchange,Lync,Sharepoint都用PowerShell进行管理,但是面对 WSUS却傻了眼。经过一番搜索,在网上发现了一个好东西——PoshWSUS[http://poshwsus.codeplex.com/]
没什么好说的,我要用的功能都有。但这个脚本的发布者没有说明使用方法,研究后在这里和大家分享一下。
1.在WSUS服务器上安装PowerShell 2.0
2.将下载的PoshWSUS1_1.psm1复制到D:\WSUSScript\PoshWSUS\目录下
3.运行PowerShell,在命令提示行输入:
- Import-Module -Name "D:\WSUSScript\PoshWSUS\PoshWSUS1_1.psm1"
- Connect-WSUSServer -wsusserver "WSUS的服务器名"
4.接下来就可以根据自己的需要运行自己想做的事情啦。以我的需求为例:
a).将"PC1"添加到"GroupA"组:
- Add-WSUSClientToGroup -group "GroupA" -computer "PC1"
到图形界面检查一下效果,如果没有问题就可以批量操作啦!方法如下:
i.在D:\WSUSScript\PoshWSUS\目录下新建Computer2Group.csv文件,第一行写computer,以下每行都是需要处理的计算机名
ii.根据CSV批量添加指定的计算机到"GroupA"组:
Import-Csv -path "D:\WSUSScript\PoshWSUS\Computer2Group.csv" | ForEach {Add-WSUSClientToGroup -group "GroupA" -computer $_.Computer}
看看效果吧!这个功能只是抛砖引玉,其他命令行多了去了,如下:
- Current commands are:
- Add-WSUSClientToGroup
- Approve-WSUSUpdate
- Connect-WSUSServer
- Convert-WSUSTargetGroup
- Deny-WSUSUpdate
- Disconnect-WSUSServer
- Get-WSUSChildServers
- Get-WSUSClient
- Get-WSUSClientGroupMembership
- Get-WSUSClients
- Get-WSUSClientsInGroup
- Get-WSUSCommands
- Get-WSUSContentDownloadProgress
- Get-WSUSDatabaseConfig
- Get-WSUSDownstreamServers
- Get-WSUSEmailConfig
- Get-WSUSEvents
- Get-WSUSGroup
- Get-WSUSGroups
- Get-WSUSServer
- Get-WSUSStatus
- Get-WSUSSubscription
- Get-WSUSSyncHistory
- Get-WSUSSyncProgress
- Get-WSUSUpdate
- Get-WSUSUpdateCategories
- Get-WSUSUpdates
- New-WSUSGroup
- Remove-WSUSClient
- Remove-WSUSClientFromGroup
- Remove-WSUSGroup
- Remove-WSUSUpdate
- Resume-WSUSDownloads
- Resume-WSUSUpdateDownload
- Set-WSUSEmailConfig
- Start-WSUSCleanup
- Start-WSUSSync
- Stop-WSUSDownloads
- Stop-WSUSSync
- Stop-WSUSUpdateDownload
- New-WSUSInstallApprovalRule
- Set-WSUSInstallApprovalRule
- Get-WSUSInstallApprovalRules
- Remove-WSUSInstallApprovalRule
- Start-WSUSInstallApprovalRule
- Connect-WSUSDatabaseServer
- Test-WSUSDatabaseServerConnection
- Get-WSUSUpdateClassifications
每个命令的使用方法在脚本中都能找到,真是无比激动,希望各位喜欢!!