Redistribute failed packages

# Redistribute failed packages without clicking view status -> redistribute package

$SiteCode = “P01”

$PackageState = “3”

$FailedPackages = Get-WmiObject -Namespace “Root\SMS\Site_$($SiteCode)” -Query “select * from SMS_PackageStatusDistPointsSummarizer where state = $($PackageState)”

if ($FailedPackages.Count -gt 0)

{

Write-Host “There are $($FailedPackages.Count) Failed Packages at the moment.”

}

elseif ($FailedPackages)

{

Write-Host “There is 1 Failed Package at the moment.”

}

else

{

Write-Host “There are 0 at the moment.”

}

if ($FailedPackages)

{

foreach ($FailedPackage in $FailedPackages)

{

try

{

$DistributionPointObj = Get-WmiObject -Namespace “root\SMS\Site_$($SiteCode)” -Class SMS_DistributionPoint -Filter “PackageID=’$($FailedPackage.PackageID)’ and ServerNALPath like ‘%$($FailedPackage.ServerNALPath.Substring(12,7))%’”

$DistributionPointObj.RefreshNow = $True

$result = $DistributionPointObj.Put()

Write-Host “Refreshed $($FailedPackage.PackageID) on $($FailedPackage.ServerNALPath.Substring(12,7)) – State was: $($FailedPackage.State)”

}

catch

{

Write-Host “Unable to refresh package $($FailedPackage.PackageID) on $($FailedPackage.ServerNALPath.Substring(12,7)) – State was: $($FailedPackage.State)”

write-host $Error

}

}

}

https://social.technet.microsoft.com/Forums/office/en-US/36d083ef-6310-4d64-b4a7-031ee96a9d2f/sccm-2012-powershell-redistribute-failed-packages?forum=configmanagersdk


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *