【问题标题】:How to update power-shell to 5.1 remotely using power-shell?如何使用 powershell 远程将 powershell 更新到 5.1?
【发布时间】:2018-11-21 01:14:55
【问题描述】:

我最近被分配了一项任务,将我们所有平台上的 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.

【问题讨论】:

  • 使用 WSUS 并正确部署补丁。
  • @TheIncorrigible1 服务器不在域中。
  • 那么他们不应该在环境中????
  • @TheIncorrigible1 我的公司使用 rAG(Rollout Automation Gear)是一种便于在一个或多个服务器中远程执行操作的工具,为此我需要部署一个 PS 脚本。
  • 服务器是64位还是32位?错误表明它可能是 32。

标签: powershell powershell-remoting


【解决方案1】:

更新我的问题的解决方案如下:

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" }

}

【讨论】:

    猜你喜欢
    • 2021-06-25
    • 2022-10-07
    • 1970-01-01
    • 1970-01-01
    • 2016-03-16
    • 2019-03-19
    • 1970-01-01
    • 2012-05-05
    • 1970-01-01
    相关资源
    最近更新 更多