$SITESERVER = 'Your SiteServer'
$SITECODE = 'Your Sitecode'
$FAILED = Get-WmiObject -computername $SITESERVER -Namespace "root\SMS\Site_$SITECODE" -Query "Select * From SMS_PackageStatusDistPointsSummarizer where (State = 2 OR state = 3 OR State = 8)"
if ($FAILED)
{
foreach ($i in $FAILED)
{
Write-host "Package ID:"$i.PackageID"`nState:"$i.State"`nServerNalPath:"$i.ServerNALPath"`n" -ForegroundColor Red
}
Write-Host $FAILED.count "Objects failed to distribution`n" -ForegroundColor Red
Write-host "State 2 = INSTALL_RETRYING`tState 3 = INSTALL_FAILED`tState 8 = VALIDATION_FAILED" -ForegroundColor Cyan
}
else
{
Write-Host "No Objects failed to distribute" -ForegroundColor DarkGreen
}
Write-host "Press a key to start Redistribution" -ForegroundColor Cyan
Pause
$count = $FAILED.count
foreach ($i in $FAILED)
{
Write-host ($count--)" - Refreshing "$i.PackageID -ForegroundColor Cyan
$Objectid = Get-WmiObject -computername $SITESERVER -Namespace "root\SMS\Site_$SITECODE" -Query "Select * From SMS_DistributionPoint WHERE PackageID='$($i.PackageID)' AND ServerNALPath like '%$($i.ServerNALPath.Substring(12,10))%'"
$Objectid.RefreshNow = $True
[Void]$Objectid.Put()
}
A simple blog about my experience using Powershell with SCCM 2012 and current branch.
Thursday, April 14, 2016
SCCM 2012 Redistribute all packages to distribution points with state INSTALL_RETRYING, INSTALL_FAILED or VALIDATION_FAILED. use as script
In case you sometimes have applications, Packages or Driver packages failed (State 2,3 or 8) to distribute to some Distribution points in SCCM 2012 you can use this script to re-sync them to the appropriate Distribution Points. It's easy to use because you don't need the SCCM management console for it, just make sure you use an account that has a appropriate security level to perform this action.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment