I have been assigned a task recently to update our power-shell to version 5 on all our platform. I have been able to detect which servers need to be updated but at the moment I am stuck with actually updating it. I can run the silent installer but it doesn't do anything.
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
}
Note i tried using dism.exe.
Invoke-Command{
dism.exe /online /add-package /PackagePath:C:\Temp\KB3191564-x64.cab /norestart
#Remove-Item c:\temp\KB3191564-x64.cab
}
This is the error I got:
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.
To update the resolution to my question was as following :
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" }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.