我最近被分配了一项任务,将我们的power-shell更新到我们所有平台上的第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:\Temp\Win8.1AndW2K12R2-KB3191564-x64.msu" "/q /norestart" -Wait
}
注意我尝试使用dism.exe。
Invoke-Command{
dism.exe /online /add-package /PackagePath:C:\Temp\KB3191564-x64.cab /norestart
#Remove-Item c:\temp\KB3191564-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.
答案 0 :(得分:0)
要更新我的问题的解决方案如下:
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:\Temp\Win8.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:\Temp\KB3191564-x64.cab
/norestart
#Remove-Item c:\temp\KB3191564-x64.cab
} } elseif
($architecture.addresswidth -eq "32"){ throw "Error Message" }
}