Private/SCCMDeployments/_GetSCCMDeploymentStatistics.ps1
function _GetSCCMDeploymentStatistics { [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( <#Category#>'PSUseSingularNouns', <#CheckId#>'', Scope = 'Function', Justification = 'This is getting multiple statistics about a deployment.' )] param ( [Parameter(HelpMessage = 'This runs a contains unless you specify -ExactMatch.')] [string]$Deployment, [switch]$ExactMatch ) begin { $Object = @() } process { $DeploymentSplat = @{ Route = 'wmi' Connector = 'SMS_DeploymentSummary' FilterField = 'ApplicationName' FilterString = $Deployment } if ($ExactMatch) { $DeploymentSplat += @{ ExactMatch = $true } } $MatchingDeployments = _GetSCCMInformationQuerySTT @DeploymentSplat foreach ($Item in $MatchingDeployments) { $Object += [PSCustomObject]@{ Name = $Item.ApplicationName Collection = $Item.CollectionName 'Deployment Time' = "$(([datetime]::SpecifyKind($Item.DeploymentTime, 'UTC')).tolocaltime())" | Get-Date -Format 'M/dd/yyyy h:mm:ss tt' 'Targeted Systems' = $Item.NumberTargeted 'Success Percentage' = "$([math]::Round(($Item.NumberSuccess / $Item.NumberTargeted) * 100, 1))%" Successful = $Item.NumberSuccess Errors = $Item.NumberErrors 'In Progress' = $Item.NumberInProgress Other = $Item.NumberOther 'Unknown Status' = $Item.NumberUnknown 'Last Summarized' = "$(([datetime]::SpecifyKind($Item.SummarizationTime, 'UTC')).tolocaltime())" | Get-Date -Format 'M/dd/yyyy h:mm:ss tt' } } } end { return $Object } } |