# SCCM script to find Application Dependencies

**URL:** <https://forums.powershell.org/t/sccm-script-to-find-application-dependencies/5740>\
**Category:** PowerShell Help\
**Created:** [February 9, 2016, 12:48am UTC](https://forums.powershell.org/t/sccm-script-to-find-application-dependencies/5740 "2016-02-09T00:48:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![graham-beer1](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@graham-beer1](https://forums.powershell.org/u/graham-beer1)\
**Post date:** [February 9, 2016, 12:48am UTC](https://forums.powershell.org/t/sccm-script-to-find-application-dependencies/5740/1 "2016-02-09T00:48:37Z")

</div>

Hi,

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 { 

    [CmdletBinding()] 
    param (  
    [parameter(ValueFromPipeline=$true,     
	    ValueFromPipelineByPropertyName=$true)]   
    [string]$Application
    )

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} | 
            #Results
            select @{name="Application Dependencies for $Application";expression={$PSItem.LocalizedDisplayName}}
            }
}

End {
    #Will display results  
}

}#End of Function
```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:42pm UTC](https://forums.powershell.org/t/sccm-script-to-find-application-dependencies/5740/2 "2024-05-16T20:42:58Z")

</div>

Closed on May 16, 2024, 8:42pm UTC


