本文介绍了在本地服务器上使用Powershell脚本应用Service Pack(.msu文件)更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该脚本的主要作用是从某个位置获取.msu文件,然后将其复制到"C:\ temp \"文件夹中.然后,脚本将获取所有.msu文件,并将名称存储在数组中.使用foreach循环,它尝试将.msu更新应用于运行脚本的本地服务器.

What it basically does is the script gets the .msu files from a location and copies to the "C:\temp\" folder.Then the script gets all the .msu files and stores the names in the array.Using the foreach loop it tries to apply the .msu updates to the local server where the script is running.

但是,当我运行脚本时.它什么也没做.

However when i run the script. It doesn't do anything.

下面是代码

$from="sourceLocation\*.msu"
$to="C:\temp\"
Copy-Item $from $to -Recurse -Force
$listOfMSUs= (Get-ChildItem –Path $to -Filter "*.msu").Name
Write-Host $listOfMSUs

if($listOfMSUs)
{
    foreach($msu in $listOfMSUs)
    {
    Write-Host "Processing The Update"
    &  wusa $to$msu /quiet /norestart         
    }
}
else{

Write-Host "MSUs doesnt exists"
}

有什么建议吗?

推荐答案

答案很简单.我需要的只是一个/install命令参数.因此,该行应为

The answer was simple. All i needed was a /install command parameter.So the line should be

 & wusa /install $to$msu  /quiet /norestart 

 OR

  & wusa $to$msu  /quiet /norestart 

这篇关于在本地服务器上使用Powershell脚本应用Service Pack(.msu文件)更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 17:50