Here’s a little script I wrote based on one written by David O’Brien that allows you to redistribute failed package distributions in Configuration Manager by selecting which packages you want to redistribute.
First the script queries WMI to find packages that are not in the “installed” state, ie the distribution is not successfully completed. It will then display these in PowerShell’s gridview so you can view details about the package and the distribution.
Simply select which packages you wish to redistribute and click OK.
Using the “Distribution Point Job Queue Manager” available from the Configuration Manager toolkit is a great way to monitor the distributions:
Invoke-PackageRedistribution
Enter your sitecode at the top of the script, and run in on your site server.
$SiteCode = "ABC" $failures = Get-WmiObject -Namespace root\sms\site_$SiteCode -Query "SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE State <> 0" | Select ServerNALPath,LastCopied,PackageType,State,PackageID,SummaryDate | ForEach-Object { $PKG = Get-WmiObject -NameSpace root\sms\site_$SiteCode -Class SMS_Packagebaseclass -Filter "PackageID = '$($_.PackageID)'" | Select Name,PackageSize $server = $_.ServerNALPath.Split("\\")[2] $size = $PKG.PackageSize / 1KB $State = switch ($_.State) { 1 {"Install_Pending"} 2 {"Install_Retrying"} 3 {"Install_Failed"} 4 {"Removal_Pending"} 5 {"Removal_Retrying"} 6 {"Removal_Failed"} 7 {"Instal_Start_Pending"} 8 {"Content Validation Failed"} } $Type = switch ($_.PackageType) { 0 {"Standard Package"} 3 {"Driver Package"} 4 {"Task Sequence Package"} 5 {"Software Update Package"} 6 {"Device Setting Package"} 7 {"Virtual App Package"} 8 {"Application Package"} 257 {"OS Image Package"} 258 {"Boot Image Package"} 259 {"OS Install Package"} } $LastCopied = [System.Management.ManagementDateTimeconverter]::ToDateTime($_.LastCopied) $SummaryDate = [System.Management.ManagementDateTimeconverter]::ToDateTime($_.SummaryDate) New-Object psobject -Property @{ Name = $PKG.Name 'PackageSize (MB)' = $size PackageType = $Type PackageID = $_.PackageID State = $State StateCode = $_.State DistributionPoint = $server LastCopied = $LastCopied SummaryDate = $SummaryDate } } | Select Name,'PackageSize (MB)',PackageType,PackageID,State,StateCode,DistributionPoint,LastCopied,SummaryDate | Sort LastCopied -Descending | Out-GridView -Title "Select package/s to redistribute" -OutputMode Multiple | ForEach-Object { Get-WmiObject -Namespace root\sms\site_$SiteCode -Query "SELECT * FROM SMS_DistributionPoint WHERE PackageID='$($_.PackageID)' and ServerNALPath like '%$($_.DistributionPoint)%'" | ForEach-Object { $_.RefreshNow = $true $_.Put() } }
This is nothing but GENIOUS! Thank you so much. Only issue is, that it takes about 10 minutes to launch, but definately not a deal breaker.
10 minutes?! You must have a ton of package content!
Hey,
when I run the script, I get the following error message:
Exception calling “ToDateTime” with “1” argument(s): “Specified argument was out of the range of valid values.
Parameter name: dmtfDate”
At redist.ps1:32 char:13
+ $LastCopied = [System.Management.ManagementDateTimeconverter]::ToDat …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentOutOfRangeException
Did I forget to set a variable?
Hmm maybe the datetime value in WMI is not present or corrupted?
Thanks a lot, saw lots of scripts for this issue – none really worked, but this one worked a treat!
My tool is empty. I know there are over 200+ failed packages. Any ideas on what may be wrong?