Install Windows Update Standalone Installer remotely

This topic contains 5 replies, has 2 voices, and was last updated by Profile photo of powershelluser143 powershelluser143 1 month ago.

  • Author
    Posts
  • #65308
    Profile photo of powershelluser143
    powershelluser143
    Participant

    Hello all I am trying to install an update using PowerShell my current line of code is as follows which is working in local machine

    $path = "D:\mysoftware-x64.msu"
    Start-Process "$($env:WINDIR)\system32\wusa.exe" -ArgumentList "$path /quiet" -Wait
    

    I tried by using the invoke-coomand as follows

    Invoke-command -computername ss -scriptblock { Start-Process "$($env:WINDIR)\system32\wusa.exe" -ArgumentList "$path /quiet" -Wait }

    So can some one help me on this, I tried psexec but in vain

  • #65311
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

    Unfortunately, the installation of Windows Updates doesn't work in a PowerShell Remoting session.

    Alternative options known to work are:
    – PowerShell Desired State Configuration
    – Transfer the update file onto the box, create and execute a scheduled task to install it
    – Leverage tools like Ansible, Chef or Puppet

  • #65346
    Profile photo of powershelluser143
    powershelluser143
    Participant

    I don't want to execute it as scheduled task, can you give me some idea on how to achieve this with DSC. I tried but it is asking for some mof files. I am getting error like The computer-specific MOF file for computer localhost does not exist in the current directory.

  • #65347
    Profile photo of powershelluser143
    powershelluser143
    Participant

    I tried this way but I got the exception saying when I run in remotely

    The WS-Management service cannot process the request. The CIM namespace root/Microsoft/Windows/DesiredStateConfiguration is invalid.
    + CategoryInfo : ObjectNotFound: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : HRESULT 0x80338000
    + PSComputerName : testmachine

    The WS-Management service cannot process the request. The CIM namespace root/Microsoft/Windows/DesiredStateConfiguration is invalid.
    + CategoryInfo : ObjectNotFound: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : HRESULT 0x80338000
    + PSComputerName : testmachine

    Configuration V5Install
    {
        node "$env:COMPUTERNAME"
        {
    
            LocalConfigurationManager
            {
                RebootNodeIfNeeded = $true
            }
    
            Package InstallPowerShell_V5
            {
                Name = "PowerShellV5"
                Path = "$($env:WINDIR)\system32\wusa.exe"
                ProductId = ""
                Arguments = "C:\Windows\Temp\W2K12-KB3134759-x64.msu /quiet"
            }
        }
    }
    
    V5Install -OutputPath $env:SystemDrive:\DSCconfig -Verbose
    Set-DscLocalConfigurationManager -ComputerName $env:COMPUTERNAME -Path $env:SystemDrive\DSCconfig
    Start-DscConfiguration -ComputerName $env:COMPUTERNAME -Path $env:SystemDrive:\DSCconfig  -Wait -Force
    
  • #65350
    Profile photo of powershelluser143
    powershelluser143
    Participant

    Another try which I tested locally fails

    Configuration V5Install
    {
        node "$env:COMPUTERNAME"
        {
    
            LocalConfigurationManager
            {
                RebootNodeIfNeeded = $true
            }
    
            Package InstallPowerShell_V5
            {
                Name = "PowerShellV5"
                Path = "$($env:WINDIR)\system32\wusa.exe"
                ProductId = ""
                Arguments = "C:\Windows\Temp\W2K12-KB3134759-x64.msu /quiet"
            }
        }
    }
    
    V5Install -OutputPath $env:SystemDrive:\DSCconfig -Verbose
    Set-DscLocalConfigurationManager -ComputerName $env:COMPUTERNAME -Path $env:SystemDrive\DSCconfig
    Start-DscConfiguration -ComputerName $env:COMPUTERNAME -Path $env:SystemDrive:\DSCconfig  -Wait -Force

    Error message recieved

      PowerShell DSC resource MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: The return code 1058 was
      not expected. Configuration is likely not correct
      + CategoryInfo : InvalidOperation: (:) [], CimException
      + FullyQualifiedErrorId : ProviderOperationExecutionFailure
      + PSComputerName : localhost

      The SendConfigurationApply function did not succeed.
      + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
      + FullyQualifiedErrorId : MI RESULT 1
      + PSComputerName : localhost

  • #65359
    Profile photo of powershelluser143
    powershelluser143
    Participant

    My remote machine doesn't have PowerShell V5 installed can I execute DSC commands remotely

You must be logged in to reply to this topic.