1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Powershell for automatize windows update and program installation

Discussion in 'Windows 10' started by erotavlas, 2016/01/08.

  1. 2016/01/08
    erotavlas

    erotavlas New Member Thread Starter

    Joined:
    2016/01/08
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    3
    Computer Experience:
    Experienced
    Hi,
    I come from linux world. I'm currently writing a script in order to automatize the updating of windows OS and the installation of programs.
    I'm using the chocolately packages manager together with this script https://gallery.technet.microsoft.com/scriptcenter/2d191bcd-3308-4edd-9de2-88dff796b0bc that it is also available in chocolately repository.
    I have a problem about setting the ServiceManager. I cannot register to Microsoft Update service. I do not how to do this. These are few row of my script.
    Code:
    Import-Module PSWindowsUpdate
    Get-WUServiceManager
    
    ServiceID                            IsManaged IsDefault Name
    ---------                            --------- --------- ----
    117cab2d-82b1-4b5a-a08c-4d62dbee7782 False     False     Windows Store
    855e8a7c-ecb4-4ca3-b045-1dfa50104289 False     False     Windows Store (DCat Prod)
    9482f4b4-e343-43b6-b170-9a65bc822c77 False     True      Windows Update
    
    Get-WUList -MicrosoftUpdate
    
    WARNING: Can't find registered service Microsoft Update. Use Get-WUServiceManager to get registered service.
    
    Get-WUInstall -MicrosoftUpdate -IgnoreUserInput -AcceptAll -Verbose 
    
    WARNING: Can't find registered service Microsoft Update. Use Get-WUServiceManager to get registered service.
    
    If I use the following syntax by substituting MicrosoftUpdate with WindowsUpdate, it works well.

    Code:
    Get-WUList -WindowsUpdate
    
    ComputerName Status KB          Size Title
    ------------ ------ --          ---- -----
    DESKTOP-7... D----- KB890830   48 MB Windows Malicious Software Removal Tool for Windows 8, 8.1, 10 and Windows Serv...
    DESKTOP-7... D----- KB3124200 300 MB Cumulative Update for Windows 10 Version 1511 for x64-based Systems (KB3124200)
    DESKTOP-7... D----- KB3132372  18 MB Security Update for Internet Explorer Flash Player for Windows 10 Version 1511 ...
    DESKTOP-7... D----- KB3133431  18 MB Update for Internet Explorer Flash Player for Windows 10 Version 1511 for x64-b...
    
    I made a lot of search on the web without success. I also read the help documentation
    help Get-WUServiceManager -full | -examples

    Thank you
     
  2. 2016/01/08
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    14,916
    Likes Received:
    379
    Trophy Points:
    1,093
    Because there is no MicrosoftUpdate service? There's only a Windows Update service (wuauserv).
     
    Arie,
    #2

  3. to hide this advert.

  4. 2016/01/08
    erotavlas

    erotavlas New Member Thread Starter

    Joined:
    2016/01/08
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    3
    Computer Experience:
    Experienced
  5. 2016/01/09
    erotavlas

    erotavlas New Member Thread Starter

    Joined:
    2016/01/08
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    3
    Computer Experience:
    Experienced
    Moreover, I forgot to mention that the help
    Code:
    help Get-WUInstall
    
    contains the -MicrosoftUpdate option
    Code:
    
    NAME
        Get-WUInstall
    
    SYNOPSIS
        Download and install updates.
    
    
    SYNTAX
        Get-WUInstall [[-UpdateType] <String>] [[-UpdateID] <String[]>] [[-RevisionNumber] <Int32>] [[-CategoryIDs]
        <String[]>] [-IsInstalled] [-IsHidden] [-WithHidden] [[-Criteria] <String>] [-ShowSearchCriteria] [[-Category]
        <String[]>] [[-KBArticleID] <String[]>] [[-Title] <String>] [[-NotCategory] <String[]>] [[-NotKBArticleID]
        <String[]>] [[-NotTitle] <String>] [-IgnoreUserInput] [-IgnoreRebootRequired] [[-ServiceID] <String>]
        [-WindowsUpdate] [-MicrosoftUpdate] [-ListOnly] [-DownloadOnly] [-AcceptAll] [-AutoReboot] [-IgnoreReboot]
        [-AutoSelectOnly] [-Debuger] [-WhatIf] [-Confirm] [<CommonParameters>]
    
     
  6. 2016/01/09
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    14,916
    Likes Received:
    379
    Trophy Points:
    1,093
    Verified on the following platforms

    Windows 10 No

    If you run Get-Service from PowerShell you'll get a list of the services installed on your computer.
     
    Arie,
    #5
    erotavlas likes this.
  7. 2016/01/10
    erotavlas

    erotavlas New Member Thread Starter

    Joined:
    2016/01/08
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    3
    Computer Experience:
    Experienced
    I found the solution. I have to type
    Code:
    Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d 
    
    in order to obtain the MicrosoftUpdate service. Now the final problem is that I cannot automate such operation since is still required the user interaction.
    Any suggestion?
     
  8. 2016/01/12
    erotavlas

    erotavlas New Member Thread Starter

    Joined:
    2016/01/08
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    3
    Computer Experience:
    Experienced
    Hi,
    I have finally found the final solution.
    Code:
    Import-Module PSWindowsUpdate
    Get-WUServiceManager
    Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false
    Get-WUInstall -MicrosoftUpdate -IgnoreUserInput -AcceptAll -IgnoreReboot -Verbose
    
    It works well on Windows 7/8/10 64 bit.
     
    Arie likes this.

Share This Page