Update* issue was fixed with SP2/R2 SP1.
A few weeks back I started to build a new build and capture task sequence for a customer and stumbled over this this problem…again. I had a script to look for those nasty updates from Alex Verboon which works fine if you have just a few Software Update Groups but is rather uncomfortable if you have many. There also was a script from the Deployment Guys which works for MDT deployments.
My problem was that I wasted a whole day (TS took 6 hrs to get to the point of failing) figuring out that Microsoft added new updates in its March Patch release and I did not look for those. So I started to write a little Powershell script which looks at the KB article from Microsoft, gets the KB Numbers, pipes them into ConfigMgr and creates (or updates) a Software Update Group so you can easily manage the membership of the updates in other groups.
The Script is pretty simple, feel free to use it and update it as you wish. Just copy it and run it. .\Create-TSFailUpdatesGroup.ps1 -SiteCode PS1 -SUGName TSFAilUpdates
If you have any remarks, put them in the comments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
<# .SYNOPSIS This Script checks http://support.microsoft.com/kb/2894518 for all Software Updates which are causing multiple restarts during a ConfigMgr Task Sequence and creates Software Update Group in ConfigMgr to ease the managemangt of the deployments of these Updates. !! MAKE sure your IE Enhanced security Configuration is disabled and your server has access to the internet !! .EXAMPLE .\Create-TSFailUpdatesGroup.ps1 -SiteCode PS1 -SUGName TSFAilUpdates Connects to Site PS1, checks for updates online and if the Updategroup "TSFAilUpdates" already exists. If the UpdateGroup already exists it checks if the update already is a member and adds it if its not. .NOTES Script name: Create-TSFailUpdatesGroup.ps1 Author: Philipp Boerner creation date: 17.05.2015 #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,Position=1,HelpMessage="Define SiteCode for your ConfigMgr deployment")] [String]$SiteCode, [Parameter(Mandatory=$false,Position=2,HelpMessage="Provide a Name for the UpdateGroup. Default is TSFailUpdates ")] $SUGName="TSFailUpdates" ) #Start Vars $KBIDs = $PSScriptRoot + "\KBIDs.txt" $url = "http://support.microsoft.com/kb/2894518" $UpdateGroupMembers = @() $TSFailUpdates = @() #End Vars # getting content from web request $web = Invoke-WebRequest $url $Links = ($web.AllElements | Where Class -eq “pLink”).innerText foreach ($link in $links) { $TSFailUpdates += $link.Substring($link.LastIndexOf("/kb/") +3).Trim().Replace("/","").Replace(")","") } $TSFailUpdates = $TSFailUpdates.Trim() Write-Host "Update KB numbers" $TSFailUpdates #Load ConfigManager Module import-module $Env:SMS_ADMIN_UI_PATH\..\ConfigurationManager.psd1 Set-Location $sitecode":" foreach ($TsFailupdate in $TSFailUpdates) { $UpdateGroupMembers += (Get-CMSoftwareUpdate -Name *$TSFailUpdate*).CI_ID } #getting rid of the leading 0 by exporting and importing again $UpdateGroupMembers | out-file $KBIDs $kbs = Get-Content $KBIDs if (Get-CMSoftwareUpdateGroup -Name $SUGName) { $SUGroup = Get-CMSoftwareUpdateGroup -Name $SUGName foreach ($kb in $Kbs) { #checking if SUG already exists if ($SUGroup.Updates -contains $kb) { Write-Verbose "$kb is already in $SUGName" } else { Write-Verbose "Adding $KB to $SUGName" Add-CMSoftwareUpdateToGroup -SoftwareUpdateGroupName $SUGname -SoftwareUpdateID $kb } } } else { Write-Verbose "Creating UpdateGroup $SUGName and adding missing updates" New-CMSoftwareUpdateGroup -Name $SUGName -UpdateId $kbs } #Cleaning up Remove-Item $KBIDs #removes input file from ScriptRoot Clear-Variable TSFailUpdates #returning to ScriptRoot Set-Location $PSScriptRoot |
Update*
Microsoft fixed this issue with the 2012 SP2/R2 SP1 release. You now get the option to retry the Updates in the Install Updates Task Sequence step.
I tried the the “retry this step……” option, but still my TS fails
When I run the script I get the following 2 errors:
Method invocation failed because [System.Object[]] does not contain a method named ‘Trim’.
At D:\PS Script\Create-TSFailUpdatesGroup.ps1:40 char:1
+ $TSFailUpdates = $TSFailUpdates.Trim()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Update KB numbers
New-CMSoftwareUpdateGroup : Cannot validate argument on parameter ‘UpdateId’. The argument is null or empty. Provide
an argument that is not null or empty, and then try the command again.
At D:\PS Script\Create-TSFailUpdatesGroup.ps1:83 char:56
+ New-CMSoftwareUpdateGroup -Name $SUGName -UpdateId $kbs
+ ~~~~
+ CategoryInfo : InvalidData: (:) [New-CMSoftwareUpdateGroup], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ConfigurationManagement.Cmdlets.Sum.Commands.
NewSoftwareUpdateGroupCommand
Thanks
try running the script in a folder without a space in it. “PS script” = “psscript”