Offline Servicing of VHDs against WSUS

Every month we are hit by Microsoft's patchday. And every month the same workflow fires: learn about updates, test, approve some, check compliance and manually fix machines with failed updates. But don't think you are done. You still need to update your offline VHDs.

5 Star
3,069 times
Add to favorites
Windows Update
E-mail Twitter Digg Facebook
  • The variable '$Debug' cannot be retrieved because it has not been set
    4 Posts | Last post May 26, 2014
      Dear Nicholas,
      Please find below error when I run Apply-WindowsUpdate.ps1 on my WSUS server.
      I have several VMM Libraries with Offline Vhdx to update.
      I don't have any WSUS Target Group created, since WSUS is not updating the offline Vhdx servers.
      Thank you for your help.
      cmdlet Apply-WindowsUpdate.ps1 at command pipeline position 1
      Supply values for the following parameters:
      VhdPath: "\\\KHC-VMMLibrary$\VHDs"
      MountDir: "C:\Temp"
      WsusServerName: FSRV01
      WsusContentPath: "D:\WSUS"
      The variable '$Debug' cannot be retrieved because it has not been set.
      At C:\Users\Superdc\Desktop\Apply-WindowsUpdate.ps1:18 char:5
      + if ($Debug) {
      +     ~~~~~~
          + CategoryInfo          : InvalidOperation: (Debug:String) [], RuntimeException
          + FullyQualifiedErrorId : VariableIsUndefined
      The variable '$Verbose' cannot be retrieved because it has not been set.
      At C:\Users\Superdc\Desktop\Apply-WindowsUpdate.ps1:24 char:5
      + if ($Verbose) {
      +     ~~~~~~~~
          + CategoryInfo          : InvalidOperation: (Verbose:String) [], RuntimeException
          + FullyQualifiedErrorId : VariableIsUndefined
      Test-Path : Illegal characters in path.
      At C:\Users\Superdc\Desktop\Apply-WindowsUpdate.ps1:34 char:12
      + if (-Not $(Test-Path "$VhdPath")) {
      +            ~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (C:\"\\KHC-VMMLibrary$\VHDs":String) [Test-Path], ArgumentExcept 
          + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand
      C:\Users\Superdc\Desktop\Apply-WindowsUpdate.ps1 : VHD specified through parameter -VhdPath does not exist. Aborting.
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Apply-WindowsUpdate.ps1
    • Hi,
      the first thing I notice is that you specify a directory containing your VHDs. The script will only work on individual files. I will update the help to clarify this!
      In addition I need more information about your environment. What is the OS of the server on which you are executing the script? What is the version of PowerShell you are using?
      Best regards,
    • Thank you dear Nicholas for the reply,
      Basically, I am running the script on Windows Server 2012 R2 were my WSUS is installed.
      PowerShell V4.0
      It would be great if we can update all VHDs at once for VMM Library Offline VMs.
      Please advise.
      Thank you.
    • Charbel,
      it is not necessary to implement updating all VHDs ina directory because that can be done by a simple loop on the child items of a directory.
      But I am still wondering about your issues regarding $Debug and $Verbose. Can you please try to run Apply-WindowsUpdate.ps1 with command line parameters instead of waiting for PowerShell to ask for values ... like this: 
      Apply-WindowsUpdate.ps1 -VhdPath "\\\KHC-VMMLibrary$\VHDs" -MountDir "C:\Temp" -WsusServerName FSRV01 -WsusContentPath "D:\WSUS"
      Let's hope this brings us closer to a solution.
      Best regards,
  • Scanning again Microsoft Update
    2 Posts | Last post May 26, 2014
    • Hi Nicholas,
      is it possible to scan the VHD directly against Microsoft or Windows Update for the required Updates?
    • Michael,
      I am not sure I understand your question. After the VHD is mounted, it scanned against a WSUS server which may be hosted by Microsoft or by yourself.
      Best regards,
  • What is the wsuscontentpath supposed to be?
    2 Posts | Last post May 07, 2014
    • What is the $wsuscontentpath supposed to be? Just a temp directory?
    • The $WsusContentPath specifies the path of on your WSUS server containing all downloaded updates. You have configured this path during initial setup of your WSUS server. The directory is automatically shared by a WSUS server under the name of "WsusContent".
      Hope this helps!
  • Issue with Line 113 Title Property
    3 Posts | Last post December 11, 2013
    • Hi Nicholas,
      I am working with your script with Server 2012 R2 WSUS Server updating a Server 2012 offline VHDX and ran into the following:
      "At U:\adminscripts\ApplyUpdates\Apply-WindowsUpdates.ps1:113 char:13
      +             $Installables.Add($FileName, $_.Title)
      +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], PropertyNotFoundException
          + FullyQualifiedErrorId : PropertyNotFoundStrict"
      I tracked down the IInstallableItem Interface that you use via GetInstallableItem().Files and noticed it is a collection from the UpdateFile Class. So I tracked that down and noticed that the "Title" property doesn't exist there. I worked around the issue by changing line 113 "$_.Title" to "$_.Name" but..
       I'm wondering if I was doing something wrong or if there is a recent change with something ("R2" perhaps) that caused this to occur?
      Excellent script by the way, it would have taken me an embarrassing amount of time to get anything close to this!
      Thanks Again For Sharing,
    • Tim,
      thanks for your feedback! I will look into this later today and get back to you.
      Best regards,
    • Tim,
      I have updated the script. It now includes your fix - thanks for providing the solution :-) I still need to check why I have not seen this error before. I'll update this thread as soon as I have any news on this.
      Best regards,
  • issue with script
    2 Posts | Last post September 03, 2013
    • Hi,
      Script does not work in present form.  Line 139 references a physical path "F:\temp\test" instead of "$MountPath".
      Correct code on line 139 should be:
      $PackageInfo = dism /Image:"$MountPath" /Get-PackageInfo /PackagePath:"$FileName"
      Once I changed this, the script worked perfectly.  Awesome work Nicholas!
    • Adam,
      thank you for your valuable feedback. I have uploaded a fixed version of the script.
      Best regards,
11 - 15 of 15 Items