用powershell 批量卸载 windows 更新
2014-02-28 15:57
330 查看
$KBID = "KB958488" $KBID1 = "KB976902" cls function Remove-Update { $HotFixes = Get-HotFix [int]$count = 0; foreach ($HotFix in $HotFixes) { $count = $count + 1 Write-Host $count / $HotFixes.Count if (($KBID -ne $HotFix.HotfixId) -and ($KBID1 -ne $HotFix.HotfixId)) { "Inside first if" $KBID = $HotFix.HotfixId.Replace("KB", "") $RemovalCommand = "wusa.exe /uninstall /kb:$KBID /quiet /norestart" Write-Host "Removing $KBID from the target." Invoke-Expression $RemovalCommand } if ($KBID -match "All") { $KBNumber = $HotFix.HotfixId.Replace("KB", "") $RemovalCommand = "wusa.exe /uninstall /kb:$KBNumber /quiet /norestart" Write-Host "Removing update $KBNumber from the target." Invoke-Expression $RemovalCommand } if ($KBID -match "Security") { if ($HotFix.Description -match "Security") { $KBSecurity = $HotFix.HotfixId.Replace("KB", "") $RemovalCommand = "wusa.exe /uninstall /kb:$KBSecurity /quiet /norestart" Write-Host "Removing Security Update $KBSecurity from the target." Invoke-Expression $RemovalCommand } } while (@(Get-Process wusa -ErrorAction SilentlyContinue).Count -ne 0) { Start-Sleep 3 Write-Host "Waiting for update removal to finish ..." } } } Remove-Update
相关文章推荐
- 用powershell 卸载所有 windows 更新
- 使用powershell脚本批量更新客户端配置文件
- 解决Windows 7下IE11无法卸载、无法重新安装,提示安装了更新的IE版本
- 盗版WindowsServer不能更新powershell,用老的自带函数批量下载总是失败?
- 批量卸载windows程序
- windows下 python 子模块管理(安装,更新,卸载)
- 微软Windows卸载工具--可解决更新Silverlight不能成功安装问题
- windows如何批量卸载程序
- win7怎样重新安装卸载之后的Windows系统更新与补丁?
- [4月10日的脚本] 更新Windows 8 (PowerShell)
- 在世纪互联版的Microsoft Azure上做windows虚拟机的批量部署--用powershell做部署
- 使用 Azure PowerShell 监视和更新 Windows 虚拟机
- 解决Windows 7下IE11无法卸载、无法重新安装,提示安装了更新的IE版本
- 使用 Azure PowerShell 监视和更新 Windows 虚拟机
- Windows更新补丁下载、批量安装的几种方法
- 批量自动更新SVN版本库 - Windows
- 解决Windows 7下IE11无法卸载、无法重新安装,提示安装了更新的IE版本
- PowerShell 批量添加域用户(Windows 2012 R2)
- powershell 批量获取windows 硬盘使用量
- 赫然:Windows Live Writer 批量博客更新软件使用教程