Created
August 16, 2024 18:55
-
-
Save MyITGuy/83513f88c8641690493cc3dba6584692 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function Resolve-ContentIdToPackage { | |
[CmdletBinding()] | |
param( | |
[Alias('UID')] | |
[string[]]$ContentUniqueId | |
) | |
begin { | |
$SiteCode = (Get-CimInstance -ClassName SMS_Authority -Namespace root\ccm).Name.Split(':')[1] | |
$PreLocation = Get-Location | |
Set-Location -Path "${SiteCode}:" | |
} | |
process { | |
foreach ($Item In $ContentUniqueId) { | |
$OutputObject = [ordered]@{ | |
ContentUniqueId = $Item | |
} | |
Get-CimInstance -Namespace "root/sms/site_${SiteCode}" -ClassName SMS_PackageToContent -Filter "ContentUniqueId='$($OutputObject.ContentUniqueId)'" | ForEach-Object { | |
$SMS_PackageToContent = $_ | |
$SMS_PackageToContent | Get-Member -MemberType Property | Select-Object -ExpandProperty Name | ForEach-Object { | |
$PropertyName = $_ | |
$OutputObject."$($PropertyName)" = $SMS_PackageToContent."$($PropertyName)" | |
} | |
Get-CimInstance -Namespace root/sms/site_PR1 -ClassName SMS_Content -Filter "ContentId='$($_.ContentId)'" | ForEach-Object { | |
$SMS_Content = $_ | |
$SMS_Content | Get-Member -MemberType Property | Select-Object -ExpandProperty Name | ForEach-Object { | |
$PropertyName = $_ | |
$OutputObject."$($PropertyName)" = $SMS_Content."$($PropertyName)" | |
} | |
} | |
} | |
[PSCustomObject]$OutputObject | |
} | |
} | |
end { | |
$PreLocation | Set-Location | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment