Author Posts

February 27, 2017 at 10:55 am

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

February 27, 2017 at 11:24 am

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

February 28, 2017 at 5:52 am

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.

February 28, 2017 at 7:14 am

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

February 28, 2017 at 9:38 am

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

February 28, 2017 at 12:03 pm

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