New-Object -com 'Microsoft.Update.AutoUpdate' doesn't return object PS remoting

This topic contains 2 replies, has 3 voices, and was last updated by  Richard Siddaway 2 months, 3 weeks ago.

  • Author
    Posts
  • #71504

    Sam Boutros
    Participant

    I'm trying to configure Windows Update Setting on a remote computer using:

    $WUSettings = (New-Object -com 'Microsoft.Update.AutoUpdate').Settings
    $WUSettings.NotificationLevel = 3 # Download Updates but let me choose whether to install them
    $WUSettings.save()
    

    which works just fine when logged in locally to the computer. For example, I can view the settings by:

    (New-Object -com 'Microsoft.Update.AutoUpdate').Settings
    

    and I get:

    NotificationLevel         : 3
    ReadOnly                  : False
    Required                  : False
    ScheduledInstallationDay  : 0
    ScheduledInstallationTime : 3
    IncludeRecommendedUpdates : False
    NonAdministratorsElevated : True
    FeaturedUpdatesEnabled    : False
    

    The problem is the same exact code does not work when in a remote PowerShell session. Both source and target computers are Windows 2012 R2 server with PS 4 running.

    When I try to run the same commands in a PS remote session I get:

    [10.121.111.68]: PS C:\Users\Administrator\Documents> New-Object -com 'Microsoft.Update.AutoUpdate' -Verbose
    
    Settings                             ServiceEnabled                            Results                                                        
    --------                             --------------                             -------                                                        
                                                                                    System.__ComObject   
    

    Nothing under 'Settings'. Subsequently $WUSettings.save() fails since $WUSettings is now a null object and does not have the save() method.
    I validated that the PS remote session is running under the local administrator account and is elevated:

    [10.121.111.68]: PS C:\Users\Administrator\Documents>  $identity = [Security.Principal.WindowsIdentity]::GetCurrent()
     $principal = New-Object Security.Principal.WindowsPrincipal $identity
     $principal.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
    True
    [10.121.111.68]: PS C:\Users\Administrator\Documents> 
    

    Any ideas?

  • #71525

    Max Kozlov
    Participant

    I'm suspect that it (IAutomaticUpdatesSettings), just as IUpdateInstaller, can't be instantiated remotely

    with IUpdateInstaller I solve it through task scheduler

  • #71540

    Richard Siddaway
    Moderator

    Max – your suspicion is correct. You can't instantiate The Update COM objects through a emoting session. The CIM classes introduced in Windows 10/2016 do work remotely but the COM objects on older versions of Windows don't

You must be logged in to reply to this topic.