SCCM script to find Application Dependencies

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Graham Beer Graham Beer 11 months, 2 weeks ago.

  • Author
  • #35034
    Profile photo of Graham Beer
    Graham Beer


    I've written this script to look at an application passed to the function, find the CIID number from the classname 'SMS_Application', pass it to the classname SMS_AppDependenceRelation to find the CIID's assigned to the application, then pass back to 'SMS_Application' to obtain the application dependent names.

    Please with the way i approached this and overall happy with the script itself.

    Any areas i could improve on ? The feedback is helpful for my learning.

    function get-application_dependencies { 
        param (  
    Begin {
    #Set arguments to find CIID from CIM
    $Arguements = @{
        Namespace = "root\SMS\site_AAC"
        ClassName = "SMS_Application"
    Process {
    #Get CCID number from 'SMS_Application' classname for specified application to pass to "SMS_AppDependenceRelation" classname
    [int]$CIID = Get-CimInstance @Arguements |
        where { $PSItem.LocalizedDisplayName -eq $Application } |
            Sort-Object CIVersion | Select  -ExpandProperty CI_ID -last 1 #If the application has more than one revison this will use the last and active one
    #Pass CCID number to query SMS_AppDependenceRelation to find Application Dependencies. Create Custom Objects to use in foreach block
    $list =  [pscustomobject](Get-CimInstance -Namespace root\SMS\site_AAC -ClassName SMS_AppDependenceRelation).where{($PSItem.FromApplicationCIID -eq $CIID)}
    #All CI_IDs that is collated from 'FromApplicationCCID' pass through foreach block to get application name of the dependencies
    foreach ($l in $list.ToApplicationCIID) {
        Get-CimInstance -Namespace root\SMS\site_AAC -ClassName SMS_Application |
            where {$PSItem.CI_ID -eq $l} | 
                select @{name="Application Dependencies for $Application";expression={$PSItem.LocalizedDisplayName}}
    End {
        #Will display results  
    }#End of Function

You must be logged in to reply to this topic.