Answered by:
change windows update setting on a remote machine using powershell

Question
-
Hi,
I have been try to change windows update setting on a remote machine using powershell, below laid down is the way how iam trying to do this
first I enter into the pssession of that system
Enter-PSSession -ComputerName "192.168.60.202" -Credential $cred
then, create a com object of AutoUpdate which got created successfully.
$AUSettings = New-Object -ComObject Microsoft.Update.AutoUpdate
$AUSettings.Settings.NotificationLevel = 4
wheni try to set the NotificationLevel it throws an error which states
Property 'NotificationLevel' cannot be found on this object; make sure it exists and is settable.
At line:1 char:1
+ $settings.NotificationLevel = 0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFoundAnd when i tried getting the member of Settings I got an error which states
[192.168.60.202]: PS C:\Users\admin\Documents> $AUSettings.Settings | Get-Member
Get-Member : No object has been specified to the get-member cmdlet.
At line:1 char:24
+ $AUSettings.Settings | Get-Member
+ ~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
+ FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
this is very strange 'cause when I do the same on my local machine things goes smooth and fine, iam able to set each and every property defined in Settingsthe members under $AUSettings are
[192.168.60.202]: PS C:\Users\admin\Documents> $AUSettings | Get-Member
TypeName: System.__ComObject#{4a2f5c31-cfd9-410e-b7fb-29a653973a0f}
Name MemberType Definition
---- ---------- ----------
DetectNow Method void DetectNow ()
EnableService Method void EnableService ()
Pause Method void Pause ()
Resume Method void Resume ()
ShowSettingsDialog Method void ShowSettingsDialog ()
Results Property IAutomaticUpdatesResults Results () {get}
ServiceEnabled Property bool ServiceEnabled () {get}
Settings Property IAutomaticUpdatesSettings Settings () {get}and member under Settings on local are
PS C:\Users\cloudadmin> $AUSettings.Settings | Get-Member
TypeName: System.__ComObject#{b587f5c3-f57e-485f-bbf5-0d181c5cd0dc}
Name MemberType Definition
---- ---------- ----------
CheckPermission Method bool CheckPermission (AutomaticUpdatesUserType, AutomaticUpdatesPermissionType)
Refresh Method void Refresh ()
Save Method void Save ()
FeaturedUpdatesEnabled Property bool FeaturedUpdatesEnabled () {get} {set}
IncludeRecommendedUpdates Property bool IncludeRecommendedUpdates () {get} {set}
NonAdministratorsElevated Property bool NonAdministratorsElevated () {get} {set}
NotificationLevel Property AutomaticUpdatesNotificationLevel NotificationLevel () {get} {set}
ReadOnly Property bool ReadOnly () {get}
Required Property bool Required () {get}
ScheduledInstallationDay Property AutomaticUpdatesScheduledInstallationDay ScheduledInstallationDay () {get} {set}
ScheduledInstallationTime Property int ScheduledInstallationTime () {get} {set}Iam wondering if I can access the Read-Write properties on remote computer.
thanks in advance
-Noor- Edited by noor syed Tuesday, October 16, 2012 3:54 PM
Tuesday, October 16, 2012 3:54 PM
Answers
-
New-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' -name 'AUOptions' -value '4' -propertyType "DWord" -force
Wednesday, October 17, 2012 6:36 AM
All replies
-
New-ItemProperty 'HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU' -name 'AUOptions' -value '4' -propertyType "DWord" -force
Tuesday, October 16, 2012 4:18 PM -
Hi Kazun,
I don't see WindowsUpdate in 'HKLM:\Software\Policies\Microsoft\Windows\'
-Noor
Wednesday, October 17, 2012 6:03 AM -
New-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' -name 'AUOptions' -value '4' -propertyType "DWord" -force
Wednesday, October 17, 2012 6:36 AM