Here’s a quick code to get a tree view (sort of) of applications in your ConfigMgr 2012 environment that shows dependencies, including dependencies of dependencies. Works as is, for me at least. If you spot any bugs or improvements feel free to let me know. As usual watch out for word-wrapping and typos.
Function Get-Dependency($appCIID,$appNameFunc){
gwmi -ComputerName $server -Namespace “root\sms\site_$code“ -Class SMS_AppDependenceRelation -Filter “FromApplicationCIID=’$appCIID‘“ | %{
if($_.ToApplicationCIID -ne $null){
$ToApplicationCIID = $_.ToApplicationCIID
$dependencyName = Resolve-ApplicationName $ToApplicationCIID
$dependencyNameSub = ” –>$dependencyName“
Write-Host $dependencyNameSub
Get-SubDependency $ToApplicationCIID $dependencyNameSub
}
}
return
}
Function Get-SubDependency($appCIID, $appNameFunc){
$appNamePrefix = ” “ + ($appNameFunc -split “>”)[0] + “>”
gwmi -ComputerName $server -Namespace “root\sms\site_$code“ -Class SMS_AppDependenceRelation -Filter “FromApplicationCIID=’$appCIID‘“ | %{
if($_.ToApplicationCIID -ne $null){
$ToApplicationCIID = $_.ToApplicationCIID
$dependencyName = Resolve-ApplicationName $ToApplicationCIID
$dependencyName = “$appNamePrefix$dependencyName“
Write-Host “$dependencyName“
Get-SubDependency $ToApplicationCIID $dependencyName
}
}
return
}
Function Resolve-ApplicationName($appCIID){
gwmi -ComputerName $server -Namespace “root\sms\site_$code“ -Class SMS_ApplicationLatest -Filter “CI_ID = ‘$appCIID‘” | select LocalizedDisplayName | %{
return $_.LocalizedDisplayName
}
}
cls
$server = “serverName”
$code = “001”
gwmi -ComputerName $server -Namespace “root\sms\site_$code“ -Class SMS_ApplicationLatest | %{
$appName = $_.LocalizedDisplayName
$CIID = $_.CI_ID
Write-Host “$appName“
Get-Dependency $CIID $appName
}
Sounds grate but cant get it too work for me.
Please can you show me all the parameters I need to change for my Site.
Not grate at this sort of thing.
Thank you.
you need to specify the SCCM Server with the $server variable, and the sitecode in $code. That’s all. if you get an error it’s probably a font/copy/paste problem.
Thanks will Double check the copy and paste and give it a try.
1 Last thing, does it export to file or is it a on screen display only.
Im getting error
gwmi : Generic failure
At line:2 char:1
+ gwmi -ComputerName $server -Namespace “root\sms\site_$code” -Class SMS_AppDepend …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
I did change following as you suggested.
$server = “serverName”
$code = “001”
Thanks a lot by the way.
Found the problem
Had to do a find and replace for the ‘ & “ as they don’t copy correctly.
Any quick way to PIPE it to CSV so It can be sorted/Filtered.
Hi, i got caught up in work, sorry. So it works now for you? I don’t think piping to a csv would work because of the Format of the Output. Probbly a better way then would be to create an XML document and write the top Level apps as nodes, then write subnodes for the dependencies… As is, is just a command window Output view.
Nice work Andrew. Just a question/addition:
How to check dependencies (and dependencies of dependencies) for a single application? What variabele can be used for that?
E.g. I want all the dependencies (and dep. of dep.) of ‘Microsoft Office 2010’?
Thanks
at the top of the script add this:
Param($inAppName=”ALL”)
then replace this line:
gwmi -ComputerName $server -Namespace “root\sms\site_$code” -Class SMS_ApplicationLatest | %{
with:
gwmi -ComputerName $server -Namespace “root\sms\site_$code” -Class SMS_ApplicationLatest | ?{$_.LocalizedDisplayName -like “*$inAppName*” -or $inAppName -eq ‘ALL’} | %{
then you can run the script with a Parameter for a specific application, or even a Wildcard.
Anyone checked out the SMS_AppDependenceRelation_Flat class in particular to is level property 😉