通过powershell

您所在的位置:网站首页 windows删除更新补丁 通过powershell

通过powershell

2024-06-19 20:00| 来源: 网络整理| 查看: 265

针对incredibuild 在win7上更新补丁后编译报错的问题,解决方案是卸载掉安装的系统补丁(备注:以后大家的测试环境最好不要自动更新系统补丁)

 

通过powershell-批量卸载补丁操作步骤:

1、以管理员身份运行powershell

2、执行:Set-ExecutionPolicy RemoteSigned

3、输入Y后回车

4、Remove-Update.ps1脚本拷贝至C盘根目录,然后直接将C盘的该脚本拖入到powershell窗口中执行即可

 

脚本中:

$TimeOutDays=7 字段代表卸载多久之前时间安装的补丁

比如现在本地电脑时间为7月7日,配置为7天,这样就可以卸载7月1日-7月7日之间安装的系统补丁

 

cls function Remove-Update { $TimeOutDays=7   #天数配置 [int]$count = 0; $hotfixes=(Get-HotFix | Sort-Object -Property installedon -Descending) #$lis= (Get-HotFix | Sort-Object -Property installedon -Descending) foreach ($hotfix in $hotfixes)         {  $count = $count + 1                          $installtime=$hotfix | Select-Object -ExpandProperty installedon                       $daypan=((get-date)-$installtime).days           # $lis= Get-HotFix | Sort-Object -Property installedon -Descending            if ($TimeOutDays -gt $daypan )               {  "Inside first if"                 $KBID = $hotfix.HotfixId.Replace("KB", "")                 write-host $kbid                 $RemovalCommand = "wusa.exe /uninstall /kb:$KBID /quiet /norestart"                 Write-Host "卸载 KB$KBID ,安装时间:"$installtime                 Invoke-Expression $RemovalCommand               while (@(Get-Process wusa -ErrorAction SilentlyContinue).Count -ne 0)                      { Start-Sleep 3               Write-Host "wusa.exe正在运行 ...卸载中..." }       }  } }

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3