Created
October 7, 2015 00:51
-
-
Save mrbodean/c66994593458a196001c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dp = Read-Host -Prompt "Enter the name of the DP to check:" | |
If(!($UserTSchoice)){ | |
# Get all task sequences in CM12 | |
if ($AllTaskSequences -eq $null) { | |
Write-Host -ForegroundColor Yellow "Getting Task Sequence list...may take 60 seconds" | |
$AllTaskSequences = Get-CMTaskSequence -Name "*" | Sort Name | |
$TSNames = $AllTaskSequences.Name | sort Name | |
} | |
# Display Task Sequences | |
$TSNames | Sort Name | |
# User input for task sequence | |
$UserTSchoice = Read-host "`nEnter the name of the task sequence?" | |
Write-Output "" | |
} | |
$CMServerName = Get-CMSite -SiteCode DEV|select ServerName | |
$CMServerName = $CMServerName.ServerName | |
$CMSite = Get-CMSite -SiteCode DEV|select SiteCode | |
$CMSite = $CMSite.SiteCode | |
[xml]$TS = Get-CMTaskSequence -Name $UserTSchoice| select -ExpandProperty Sequence | |
$rpkg = $ts.sequence.referenceList.reference.package | |
#Add BASE Patch Deployment Package | |
$rpkg = $rpkg + "DEV00208" | |
#Add Delta Patch Deployment Package | |
$rpkg = $rpkg + "DEV0024A" | |
Foreach($pkg in $rpkg){ | |
$i = $i+1 | |
$pkgname = Get-CMPackage -Id $pkg |select Name | |
if(!($pkgname)){$pkgname = Get-CMDriverPackage -Id $pkg |select Name} | |
if(!($pkgname)){$pkgname = Get-CMBootImage -Id $pkg |select Name} | |
if(!($pkgname)){$pkgname = Get-CMOperatingSystemImage -Id $pkg |select Name} | |
if(!($pkgname)){$pkgname = Get-CMSoftwareUpdateDeploymentPackage -Id $pkg |select Name} | |
$pkgname = $pkgname.name | |
Write-progress -Activity "Checking store $pc for: $Pkg - $pkgname" -percentcomplete ($i/$rpkg.count*100) | |
$query = Get-WmiObject –NameSpace Root\SMS\Site_$CMSite –Class SMS_DistributionDPStatus -ComputerName $CMServerName –Filter "PackageID='$pkg' And Name='$dp%'" | Select Name, MessageID, MessageState, LastUpdateDate | |
If ($query -eq $null){ | |
Write-Output "PackageID not found" | |
Write-Host "Package $Pkg - $pkgname is not on store $DP" -ForegroundColor Red | |
Write-Output "_________________________________________________________________________" | |
} | |
Foreach ($objItem in $query){ | |
$DPName = $null | |
$DPName = $objItem.Name | |
$UpdDate = [System.Management.ManagementDateTimeconverter]::ToDateTime($objItem.LastUpdateDate) | |
switch ($objItem.MessageState){ | |
1{$Status = "Success"} | |
2{$Status = "In Progress"} | |
3{$Status = "Unknown"} | |
4{$Status = "Failed"} | |
} | |
Write-output "$dpname $status" | |
IF ($Status -ne "Success") | |
{ | |
switch ($objItem.MessageID){ | |
2303{$Message = "Content was successfully refreshed"} | |
2323{$Message = "Failed to initialize NAL"} | |
2324{$Message = "Failed to access or create the content share"} | |
2330{$Message = "Content was distributed to distribution point"} | |
2354{$Message = "Failed to validate content status file"} | |
2357{$Message = "Content transfer manager was instructed to send content to Distribution Point"} | |
2360{$Message = "Status message 2360 unknown"} | |
2370{$Message = "Failed to install distribution point"} | |
2371{$Message = "Waiting for prestaged content"} | |
2372{$Message = "Waiting for content"} | |
2380{$Message = "Content evaluation has started"} | |
2381{$Message = "An evaluation task is running. Content was added to Queue"} | |
2382{$Message = "Content hash is invalid"} | |
2383{$Message = "Failed to validate content hash"} | |
2384{$Message = "Content hash has been successfully verified"} | |
2391{$Message = "Failed to connect to remote distribution point"} | |
2398{$Message = "Content Status not found"} | |
8203{$Message = "Failed to update package"} | |
8204{$Message = "Content is being distributed to the distribution Point"} | |
8211{$Message = "Failed to update package"} | |
} | |
Write-Output "Package $Pkg - $pkgname on $DPName is in '$Status' state" | |
Write-Output "Detail: $($objItem.MessageID) - $Message" | |
Write-Output "Last Update Date: $UpdDate" | |
Write-Output "_________________________________________________________________________" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment