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
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
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.
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
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
My remote machine doesn’t have PowerShell V5 installed can I execute DSC commands remotely