我最近被分配了一项任务,将我们的电源外壳更新到我们所有平台上的版本 5。我已经能够检测到哪些服务器需要更新,但目前我坚持实际更新它。我可以运行静默安装程序,但它不做任何事情。
If($PSVersionTable.PSVersion.Major -lt 5){
LogError "The following **** shall be updated: $($Global:setupConfiguration["GENERAL SETTINGS"]["CASINO_LOCATOR_NAME"])"
$fileName = "Win8.1AndW2K12R2-KB3191564-x64.msu"
$filePath = "C:Temp"
$remoteFilePath = "$($Global:globalVariables.executionPath)$fileName"
LogMessage $filePath
LogMessage $remoteFilePath
if(!(Test-Path -Path $filePath )){
New-Item -ItemType directory -Path $filePath
}
Copy-Item -Path $remoteFilePath -Destination $filePath
Start-Process "C:TempWin8.1AndW2K12R2-KB3191564-x64.msu" "/q /norestart" -Wait
}
注意我尝试使用dism.exe。
Invoke-Command{
dism.exe /online /add-package /PackagePath:C:TempKB3191564-x64.cab /norestart
#Remove-Item c:tempKB3191564-x64.cab
}
这是我得到的错误:
Deployment Image Servicing and Management tool Version: 6.3.9600.17031
Error: 11
You cannot service a running 64-bit operating system with a 32-bit version of DISM.
Please use the version of DISM that corresponds to your computer's architecture.
更新我的问题的解决方案如下:
If($PSVersionTable.PSVersion.Major -lt 5) {
LogError "The following casino shall be updated:
$($Global:setupConfiguration["GENERAL SETTINGS"]["CASINO_LOCATOR_NAME"])"
$fileName = "KB3191564-x64.cab"
$filePath = "C:Temp"
$remoteFilePath = "$($Global:globalVariables.executionPath)$fileName"
LogMessage $filePath
LogMessage $remoteFilePath
if(!(Test-Path -Path $filePath )){
New-Item -ItemType directory -Path $filePath }
Copy-Item -Path $remoteFilePath -Destination $filePath
#Start-Process "C:TempWin8.1AndW2K12R2-KB3191564-x64.msu" "/q /norestart"
-Wait
$architecture=gwmi win32_processor | select -first 1 | select addresswidth
if
($architecture.addresswidth -eq "64") { Invoke-Command {
dism.exe /online /add-package /PackagePath:C:TempKB3191564-x64.cab
/norestart
#Remove-Item c:tempKB3191564-x64.cab
} } elseif
($architecture.addresswidth -eq "32"){ throw "Error Message" }
}