Windows Update PowerShell Module

This function is a piece of PSWindowsUpdate module to manage Windows Update on a computer system running Windows. Whole module contain set of functions to check, download and install updates from PowerShell.

 
 
 
 
 
(195)
164,295 times
Add to favorites
Windows Update
12/18/2014
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • error message in powershell 2.0
    2 Posts | Last post June 19, 2015
    • It looks like in PSWindowsUpdate.psm1 you make an indescriminate call to Unblock-File it really should look more like the below to remove the error since Unblock-file is not needed if you are not running powershell 4 or above
      
      if ($PSVersionTable.PSVersion.tostring() -ge 4)
      {
      	Get-ChildItem -Path $PSScriptRoot | Unblock-File
      }
      Get-ChildItem -Path $PSScriptRoot\*.ps1 | Foreach-Object{ . $_.FullName }
      
    • The web page offering the PowerShell scripts shows POSH version 2 as the prerequisite, but "unblock-file" didn't exist prior to version 3, so it should be in a conditional testing for the major POSH version >= 3.
      
      Or, you can just ignore the error.  That's rather inelegant, but the scripts still work unless one or more of the files is marked "blocked".
  • Run get-wuinstall as non-administrative user
    1 Posts | Last post June 18, 2015
    • I have group policy set to allow non-administrators to install updates and this works. When I run get-wuinstall from non-elevated shell as non-admin user, a warning says some operations must run an elevated PowerShell Window then it checks for updates, prompts to install them and at the end there is this message: Your security policy don't allow a non-administrator identity to perform this task. The user can install via windows update so this message is confusing. Is there a way to make this work without putting the account into local admins group?
  • Running Script using winrm
    2 Posts | Last post June 17, 2015
    • I am running the following command from Server A attempting to retrieve updates on Server B using Winrm
      
      Invoke-Command -Computername ServerB -ScriptBlock {Get-WUInstall –MicrosoftUpdate –ListOnly} -Credential $USER 
      
      I get Warning:  Support local instance only, Continue....  the script runs with no output.   It runs locally with no issues.   I verified winrm is not the issue as I ran Get-Childite -Path C:\ with out any issues.
    • Needed to configure Network Service through the proxy:
      https://social.technet.microsoft.com/Forums/en-US/c4c99b78-e0e8-4bbc-b6fb-3fea3523887d/windows-update-fails-in-windows-8-rtm-behind-authenticating-proxy?forum=w8itprogeneral
  • Could not compare "1.5.1.11" to "1.5.1.11 1.5.1.11". Error: "Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Version".
    2 Posts | Last post June 17, 2015
    • The target server and the server that this script is run from both have PS V5.  Not sure why getting the error below, but when I check on the target server I'm seeing that it is running when looking at the task manager in the target server. Any thoughts it appreciated.
      
      $script ={Get-WUInstall -AcceptAll | Out-File c:\winupdate.log}
      
      PS C:\Windows\system32> invoke-WUInstall -computername Server01 -Script $script
      Could not compare "1.5.1.11" to "1.5.1.11 1.5.1.11". Error: "Cannot convert the "System.Object[]" value of type 
      "System.Object[]" to type "System.Version"."
      At C:\windows\system32\windowspowershell\v1.0\Modules\PSWindowsUpdate\Invoke-WUInstall.ps1:103 char:9
      + ...          if($ModuleTest -eq $null -or $ModuleTest.Version -lt $PSWUMo ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : ComparisonFailure
    • I've resolved it. After some looking at the Invoke-WUinstall and testing the server the I'm running from have two
      instances of the PSwindowsUpdate.  I removed one and now it is working as it should be. thanks for the script.
  • Can we search by MS number?
    1 Posts | Last post June 01, 2015
    • I like the downloadonly option. What would be the best way to use the script if all i wanted to do was download the current months patches to the machine? 
      
      Thanks
  • Bug in Module
    1 Posts | Last post May 20, 2015
    • Hi Michal, I think I may have found a bug in this module. When I run certain commandlets remotely, I get an Access Denied error. I initially thought I was doing something wrong, but after troubleshooting it over at the SpiceWorks forum, I think that there is a bug in the module. You can see all the details from SpiceWorks here: http://community.spiceworks.com/topic/954498-windows-update-module-for-powershell-access-denied-on-remote-pc-in-workgroup?page=1#entry-4626748
      Here's an example of the error and a commandlet:
      
      PS C:\WINDOWS\system32> Invoke-Command -ComputerName TestPC -ScriptBlock { Get-WUInstallerStatus } -credential TestPC\User
      Creating an instance of the COM component with CLSID {D2E0FE7F-D23E-48E1-93C0-6FA8CC346474} from the IClassFactory
      failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
          + CategoryInfo          : NotSpecified: (:) [New-Object], UnauthorizedAccessException
          + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.NewObjectCommand
          + PSComputerName        : TestPC
      
      Am I doing something wrong? Or is there a bug?
  • download and install in separate scripts
    1 Posts | Last post May 19, 2015
    • Hi, this script is great.  Im not sure if my desired approach is supported.. 
      
      1.  Get-WUInstall -WindowsUpdate -DownloadOnly -AcceptAll -verbose 
      works fine, finds all updates from ms server and downloads
      
      How do I run Get-WUInstall so that it just installs what updates it finds in downloaded status and doesnt reach back out to windows server or wsus server to check and redownload?  When I run Get-WUInstall without -WindowsUpdate or -MicrosoftUpdate it returns very quickly and finds nothing.  When I run with those switches it takes a very long time to reconnect to the update servers.
      
      
  • WSUS?
    2 Posts | Last post May 19, 2015
    • I am a COMPLETE novice to WSUS and Windows Server as i've always used Linux. Could someone explain very simply how I get the PowerShell Module to access my WSUS?
    • Its ok, I figured it out, online documentation makes it far more complex that it needs to be - so I added the location in GPCedit in audit mode, PSWindowsUpdate runs updates via WSUS when I deploy and then I delete the system GP codes to return it back to standard for the end user.
  • Error on launch PSWindowsUpdate
    4 Posts | Last post May 12, 2015
    • When I launch Import-Module PSWindowsUpdate I obtain the followind error:
      Import-Module : The specified module 'PSWindowsUpdate' was not loaded because
      no valid module file was found in any module directory.At line:1 char:1
      + Import-Module PSWindowsUpdate
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : ResourceUnavailable: (PSWindowsUpdate:String) [I
      mport-Module], FileNotFoundException
      + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
      ands.ImportModuleCommand
      What I have to do?
    • Did you place the PSWindowsUpdate folder into the
      c:\Windows\System32\WindowsPowerShell\v1.0\Modules folder?
    • I have extracted the zip file in the above location. When I try importing the module it says 
      
      Microsoft.PowerShell, C:\windows\system32\WindowsPowerShell\v1.0\Modules\PSWindowsUpdate\PSWindowsUpdate.F
      ormat.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
      
      Correct me where I have gone wrong!? 
      
      Note: I tried deleting that.ps1xml file too but still no suceess
    • You need atleast PS 2.0 - It works in 3.0 as well. So make sure you have the required, or latest powershell version installed.
      
      What version do you have now? 
  • Is there a command line switch for installing updates marked as "approved for removal"?
    1 Posts | Last post May 08, 2015
    • Hi folks
      
      The question might sound awkward at first, so here's an explanation (which, I'm sorry about, but I guess it cannot be helped, otherwise people won't get what I mean): Of course, I don't mean simply uninstalling a certain update with a known KB number, that works well with Get-WUUninstall.
      
      What I mean are those updates which technically count as "install" but in reality are an "uninstall". Maybe to clarify further: I use WSUS alongside with Local Update Publisher, where you can set the approval for certain updates to "approved for install" or to "approved for removal", as described here:
      https://technet.microsoft.com/en-us/library/dn800975.aspx
      
      To automatically install updates on shutdown on the machines in our organisations, I just have the following run on shutdwon via GPO:
      
      get-WUInstall -acceptall -IgnoreReboot
      
      With one exception, this works extremely well, all updates approved for install for a certain computer are automatically installed.
      
      However, sometimes there is the need to remove updates (such as old versions of Java, which unfortunately are not uninstalled automatically as of version 8 anymore), so I chjange the approval for old Java versions to "approved for removal".
      
      This works perfectly, the Update is detected as e.g. "(Uninstall) Java 8 Update 40" , and uninstallation is performed when I:
      
      - manually go to the GUI of Windows Update (in control panel) on a machine and hit install
      
      - manually (in the GUI of a Windows 7 machine) click "Install Updates and Shut Down"
      
      However, all those updates which are "approved for removal" are not even seen by PSWindowsUpdate, let alone "installed" (which, in this case, means "uninstalled").
      
      Do those "approved for removal" updates have a specific attribute which is by default ignored by PSWindowsUpdate? And is there a parameter I can call Get-WUInstall with to include those "approved for removal" updates? 
      
      Thanks for taking the time to read this guys!
11 - 20 of 164 Items