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.

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


  • 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!
  • Integration with MDT?
    2 Posts | Last post April 29, 2015
    • HI Michal:
      
      I would like to integrate this with MDT 2013 for our deployments. Why you ask? Because Microsoft's build in Windows Update task sequence is horribly slow; even on a gigabit connection on a brand new machine with an i7 and an SSD the Windows Update step on the task sequence can take forever; mush longer than manually running Windows Update after the fact. 
      
      Obviously I don't want my desktop support agents running Windows Update manually as they *will* forget to do it occasionally. For political reasons I cannot setup a WSUS server in our organization. 
      
      What I have done is create a new task after the applications and drivers have been installed. Run Powershell script under the "add" menu.  
      
      I run the PowerShell script line as" %SCRIPTROOT%\PSWindowsUpdate\Get-WUInstall.pst. 
      
      Under the Parameters line I chose "-AcceptAll". When I run the task sequence it appears to run the script, but does not do anything. The final summary doesn't show any errors. 
      
      I found the following on DeploymentResearch as containing the script in a wrapper:
      http://deploymentresearch.com/Research/Post/318/Using-PowerShell-scripts-with-MDT-2013
      
      Any ideas?
    • My typing sucks today. The script root I ran was:
      %SCRIPTROOT%\PSWindowsUpdate\Get-WUInstall.ps1
  • Update-WUModule : Can't unzip the latest PSWindowsUpdate module
    1 Posts | Last post April 29, 2015
    • I'm trying to update the module by running the command but I get the above error. I get the same result in an administrative and non-administrative powershell session.
      
      Any ideas?
  • Windows Update Powershell Module force updates online from Microsoft Update
    2 Posts | Last post April 29, 2015
    • I am using the Windows Update Powershell Module, and it is working.  The server I am using it on checks for updates against our internal WSUS server, unfortunately our internal WSUS server is currently not working.  From a server with a GUI when I run windows updates I can select the option "Check online for updates from Microsoft Update" and just retrieve them from an external source.  Which leads me to my question.  How can i force the Windows Update Powershell Module to check for updates from microsoft rather than our internal source?  I realize I can change GPO on my server to go to external by default, but i'm hoping there is a switch I can use with the Windows Update Powershell Module to temporarily source updates from MS rather than my internal server.
    • I ran into this issue as well. I resolved it by running the "-WindowsUpdate" switch.
      
      i.e. ( Get-WUInstall -WindowsUpdate -AcceptAll -AutoReboot )
  • is it possible to install exclusive KB ?
    1 Posts | Last post April 27, 2015
    • Hello,
      i am using your POWERSHELL scripts and play well. I have a question about exclusive KB (like service pack). Does your script manage to install it and exit with reboot status when i have a list of KB to install.
      
      Thanks a lot for any answer.
  • -autoreboot often does not seem to reboot a node on its own
    4 Posts | Last post April 23, 2015
    • Hi: 
      
      I am currently using this module to updates several machines. I notice that (even with "-Force" added  in Get-WUInstall.ps1   in latest version) some nodes do not reboot on their own and wait for a user confirmation. This keeps them from finishing their update cycle and requires manual intervention. 
      
      Is there a way to get reliable reboots upon reaching proper stage in Get-WUInstall? I am using
      
      get-wuinstall -serviceid ....... -acceptall -autoreboot -verbose.
      
      Does anyone else experience this failure to reboot automatically?
      
      Thanks.
      
      Gautam
      
    • Did you ever find an answer to your question? I am having the same problem. Thank you.
    • I have -Verbose -AcceptAll -AutoReboot at the end of my command in that exact order and have not seen the issue you are seeing.  Just in case switch order and capitalization matter.
    • Sorry - after looking closer I see I actually did put an extra command in my script to reboot after the installs and I even commented that it was added because it didn't always reboot like it should.
  • The term 'Unblock-File' is not recognized as the name of a cmdlet, function
    4 Posts | Last post April 23, 2015
    • hi, i tried to make this work but i get an error....
      i created a script: 
      >"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -Command "Import-Module PSWindowsUpdate; Get-WUInstall -AcceptAll | Out-File C:\PSWindowsUpdate.log"
      
      when i run this i get the error: 
      The term 'Unblock-File' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\PSWindowsUpdate\PSWindowsUpdate.psm1:1 char:49+ Get-ChildItem -Path $PSScriptRoot | Unblock-File <<<<+ CategoryInfo          : ObjectNotFound: (Unblock-File:String) [], CommandNotFoundException+ FullyQualifiedErrorId : CommandNotFoundException
      
      does anyone knows what this means? 
      
    • I had the same problem on Windows 7. Initially I tried to unblock each of the files in the PSWindowsUpdate Module folder but this did not resolve issue. I upgraded PowerShell to the latest version and this fixed issue for me.
    • Unblock-file was a built-in cmdlet first introduced with Powershell 3.0.
      
       I see this error on Windows 2003/2008 servers that are still running Powershell 2.0. So far, I can ignore this error if I have Unblocked the downloaded module zip file before I push to other computers. 
      
      Below is the get-help for the command.
      The Unblock-File cmdlet lets you open files that were downloaded from the Internet. It unblocks Windows PowerShell script files that were downloaded from the Internet so you can run
      them, even when the Windows PowerShell execution policy is RemoteSigned. By default, these files are blocked to protect the computer from untrusted files.
      
      Before using the Unblock-File cmdlet, review the file and its source and verify that it is safe to open.
      
      Internally, the Unblock-File cmdlet removes the Zone.Identifier alternate data stream, which has a value of "3" to indicate that it was downloaded from the Internet.
      
      For more information about Windows PowerShell execution policies, see about_Execution_Policies (http://go.microsoft.com/fwlink/?LinkID=135170).
      
      This cmdlet is introduced in Windows PowerShell 3.0.
      
    • It is buried in this Q&A but you can also resolve this by removing the line "Get-ChildItem -Path $PSScriptRoot | Unblock-File" from the beginning of the PSWindowsUpdate.psm1 file.  Then it works without updating powershell.
  • On the PSWindowsUpdate.psm1, not using global wildcard?
    2 Posts | Last post April 17, 2015
    • Hi,
      Great scripts, thank you for the tools.
      
      I was developing an in-house module to use on a Core server.  I noticed when importing the PSWindowsUpdate module, that it would pull our in-house functions as well.
      
      I found the issue that the PSWindowsUpdate.psm1 file is using a very broad wildcard. i.e.:
      Get-ChildItem -Path $PSScriptRoot\*.ps1 | Foreach-Object{ . $_.FullName }
      
      I would like to suggest it be changed to:
      Get-ChildItem -Path $PSScriptRoot\Add-WU*.ps1 | Foreach-Object{ . $_.FullName }
      Get-ChildItem -Path $PSScriptRoot\Get-WU*.ps1 | Foreach-Object{ . $_.FullName }
      Get-ChildItem -Path $PSScriptRoot\Hide-WU*.ps1 | Foreach-Object{ . $_.FullName }
      Get-ChildItem -Path $PSScriptRoot\Update-WU*.ps1 | Foreach-Object{ . $_.FullName }
      
      This way, it only pulls in the scripts specific to 'WU'.
      
      8D...ave
    • (answering my own question)
      Nevermind, figured out you need to place the files into a sub-folder with the module name.  Missed that part.  *pout/smile*
      
11 - 20 of 157 Items