Hi,
Hope the below script helps. If we get the "completed" value of $distribution_status, we can continue other tasks
$Time1 = Get-Date
start-cmContentDistribution -packageID 'test03' -distributionPointGroupName 'dpGrp1'
$PackageId = (Get-CMApplication -Name 'test03').PackageID
$distribution_status = "started"
#if the distribution is not completed within 2 hours, exit the loop
while($timediff.totalminutes -lt 120)
{
$Time2 = Get-Date
$TimeDiff = New-TimeSpan $Time1 $Time2
#$timediff.totalminutes
$all_finished = (Get-CMDistributionStatus -Id $PackageId).numbersuccess -eq (Get-CMDistributionStatus -Id $PackageId).targeted
if ($all_finished)
{
$distribution_status = "completed"
break
}
else
{
start-sleep -s 300
#"sleeping 5 minutes ..."
}
}
write-host $distribution_status
# other tasks
Alex
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi aj-47,
I'm glad the script works.
During the test, since I've already distributed the application, so I commented this line to test the remaining stuff. Hope this clarifies. And I've uncommented it to avoid the confusion made. Thanks and have a nice day!
Regards
Alex