Powershell 安装指定离线更新补丁
发布时间:2020-12-16 01:40:13 所属栏目:安全 来源:网络整理
导读:利用powershell 升级WIN7_64到POwershell 到5.1版本 当然也可以安装其它离线补丁,环境是域,当前登陆的用户是域管理员,利用WUSA和DISM安装,如果不解压直接运行.MSU文件是一闪而过,不会安装任何东西 1 $pc = ‘PC03‘ 2 3 if ((Get-HotFix -Id KB3191566 -Comp
利用powershell 升级WIN7_64到POwershell 到5.1版本 当然也可以安装其它离线补丁,环境是域,当前登陆的用户是域管理员,利用WUSA和DISM安装,如果不解压直接运行.MSU文件是一闪而过,不会安装任何东西 1 $pc=‘PC03‘ 2 3 if((Get-HotFix -Id KB3191566 -ComputerName $pc) -ne $null){ 4 5 Write-Warning "$pc 已经安装了PS 5.1补丁" 6 7 }else{ 8 9 Write-Warning "$pc 需要更新!" 10 11 Write-Warning "$pc 复制文件" 12 Copy-Item -Path ‘sccm01G$PowerShellWin7AndW2K8R2-KB3191566-x64‘ -Destination $pcD$ -Recurse -force 13 14 Invoke-Command -ComputerName $pc -ScriptBlock{ 15 16 Start-Process -FilePath ‘wusa.exe‘ -ArgumentList "d:Win7AndW2K8R2-KB3191566-x64Win7AndW2K8R2-KB3191566-x64.msu /extract:d:Win7AndW2K8R2-KB3191566-x64" -Verb RunAs -Wait -Passthru -WindowStyle Hidden 17 Write-Warning "$pc 解压文件" 18 19 Get-ChildItem -Path "d:Win7AndW2K8R2-KB3191566-x64" -Filter "*.cab"|ForEach-Object{ 20 21 $cabPath="d:Win7AndW2K8R2-KB3191566-x64"+$_.Name 22 23 Write-Warning "安装更新: $cabPath" 24 25 Start-Process -WindowStyle Hidden -FilePath ‘dism.exe‘ -ArgumentList "/online /add-package /PackagePath:$cabPath /IgnoreCheck /quiet /norestart" -Verb RunAs -Wait -PassThru 26 27 } 28 29 Write-Warning "$pc 检查补丁文件是否已安装!" 30 Get-HotFix -Id KB2809215,KB2872035,KB2872047,KB3033929,KB3191566 |Format-Table 31 32 Remove-Item -Path ‘d:Win7AndW2K8R2-KB3191566-x64‘ -Force -recurse 33 34 Write-Warning "$pc 删除临时文件" 35 } 36 37 } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |