System Centre Configuration Manager – Hide and Seek

Time to get back into System Centre, after a little break from posts on this subject! Once your Configuration Manager setup is quite, well big and built up – you may end up playing hide and seek with programs, task sequences… well any object! And trust me, from experience…its infuriating.

I know I’m probably my own worse enemy for it, but I do like using folders to categorise software. The side effect – what happens if you’ve moved it to the wrong folder, forget where you put it etc. Garrhhhhh! Yes…before someone says it…I know you could use search folders, but they arent for everyone.

I digress…

So… you have an application or package. You need to go and update it, for redistribute it. You can see it linked in Deployment, or your Task Sequence…but can you find it in the Applications or Packages tree….! NO!

I can’t take the credit for it, but there is a handy bit of powershell that will find it for you. All you need is the Package Identifier – and it will tell you where it is! Neat!

http://blog.tyang.org/2011/05/20/powershell-script-to-locate-sccm-objects-in-sccm-console/

Syntax: .\Locate-SCCMObject <SCCM Central Site Server> <SCCM Object ID>:

You must have the Configuration Manager Admin Console installed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#======================================================================================================================
# AUTHOR: Tao Yang
# DATE: 20/05/2011
# Name: Locate-SCCMObject.PS1
# Version: 1.0
# COMMENT: Use this script to locate a SCCM object in SCCM Console. Please note it does not work for SCCM collections.
# Usage: .\Locate-SCCMObject.ps1 <SCCM Central Site Server> <SCCM Object ID>
#======================================================================================================================
param([string]$CentralSiteServer,[string[]]$ObjID)
Function Get-SCCMObjectType ($ObjType)
{
Switch ($objType)
{
2 {$strObjType = "Package"}
3 {$strObjType = "Advertisement"}
7 {$strObjType = "Query"}
8 {$strObjType = "Report"}
9 {$strObjType = "Metered Product Rule"}
11 {$strObjType = "ConfigurationItem"}
14 {$strObjType = "Operating System Install Package"}
17 {$strObjType = "State Migration"}
18 {$strObjType = "Image Package"}
19 {$strObjType = "Boot Image Package"}
20 {$strObjType = "TaskSequence Package"}
21 {$strObjType = "Device Setting Package"}
23 {$strObjType = "Driver Package"}
25 {$strObjType = "Driver"}
1011 {$strObjType = "Software Update"}
2011 {$strObjType = "Configuration Item (Configuration baseline)"}
default {$strObjType = "Unknown"}
}
Return $strObjType
}
Function Get-ConsolePath ($CentralSiteProvider, $CentralSiteCode, $SCCMObj)
{
$ContainerNodeID = $SCCMObj.ContainerNodeID
$strConsolePath = $null
$bIsTopLevel = $false
$objContainer = Get-WmiObject -Namespace root\sms\site_$CentralSiteCode -Query "Select * from SMS_ObjectContainerNode Where ContainerNodeID = '$ContainerNodeID'" -ComputerName $CentralSiteProvider
$strConsolePath = $objContainer.Name
$ParentContainerID = $objContainer.ParentContainerNodeID
if ($ParentContainerID -eq 0)
{
$bIsTopLevel = $true
} else {
Do
{
$objParentContainer = Get-WmiObject -Namespace root\sms\site_$CentralSiteCode -Query "Select * from SMS_ObjectContainerNode Where ContainerNodeID = '$ParentContainerID'" -ComputerName $CentralSiteProvider
$strParentContainerName = $objParentContainer.Name
$strConsolePath = $strParentContainerName +"`\"+$strConsolePath
$ParentContainerID = $objParentContainer.ParentContainerNodeID
Remove-Variable objParentContainer, strParentContainerName
if ($ParentContainerID -eq 0) {$bIsTopLevel = $true}
} until ($bIsTopLevel -eq $true)
}
Return $strConsolePath
}
$objSite = Get-WmiObject -ComputerName $CentralSiteServer -Namespace root\sms -query "Select * from SMS_ProviderLocation WHERE ProviderForLocalSite = True"
$CentralSiteCode= $objSite.SiteCode
$CentralSiteProvider = $objSite.Machine
$SCCMObj = Get-WmiObject -Namespace root\sms\site_$CentralSiteCode -Query "Select * from SMS_ObjectContainerItem Where InstanceKey = '$objID'" -ComputerName $CentralSiteProvider
If ($SCCMObj -eq $null)
{
Write-Host "SCCM Object with ID $objID cannot be found!" -ForegroundColor Red
} else {
$strObjType = Get-SCCMObjectType $SCCMObj.ObjectType
$strConsolePath = Get-ConsolePath $CentralSiteProvider $CentralSiteCode $SCCMObj
Write-Host "Object Type`: $strObjType" -ForegroundColor Yellow
Write-Host "Console Path`: $strConsolePath" -ForegroundColor Yellow
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s