Install Windows Update Standalone Installer remotely

Welcome Forums General PowerShell Q&A Install Windows Update Standalone Installer remotely

This topic contains 5 replies, has 2 voices, and was last updated by

 
Participant
1 year, 9 months ago.

  • Author
    Posts
  • #65308

    Participant
    Points: 0
    Rank: Member

    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

    Moderator
    Points: 24
    Team Member
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

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

The topic ‘Install Windows Update Standalone Installer remotely’ is closed to new replies.