Wo habe ich nur die Collection verlinkt?

Irgendwo, ja irgendwo ist diese Collection. Nur wo?
Der folgende Report zeigt die Collection-Hierarchie:

select coll1.Name, coll1.CollectionID,
 Path =
   (case when collcoll1.SubCollectionID is null then '(ERROR: Not Linked): ' else '' end)
 + (case when collcoll9.SubCollectionID is not null then '...' else '' end)
 + (case when coll9.CollectionID is not null then coll9.Name + '\' else '' end)
 + (case when coll8.CollectionID is not null then coll8.Name + '\' else '' end)
 + (case when coll7.CollectionID is not null then coll7.Name + '\' else '' end)
 + (case when coll6.CollectionID is not null then coll6.Name + '\' else '' end)
 + (case when coll5.CollectionID is not null then coll5.Name + '\' else '' end)
 + (case when coll4.CollectionID is not null then coll4.Name + '\' else '' end)
 + (case when coll3.CollectionID is not null then coll3.Name + '\' else '' end)
 + (case when coll2.CollectionID is not null then coll2.Name + '\' else '' end)
 + (case when coll1.CollectionID is not null then coll1.Name else '' end)
from v_Collection coll1
left join v_CollectToSubCollect collcoll1 on collcoll1.SubCollectionID=coll1.CollectionID
left join v_Collection coll2 on coll2.CollectionID=collcoll1.parentCollectionID
left join v_CollectToSubCollect collcoll2 on collcoll2.SubCollectionID=coll2.CollectionID
left join v_Collection coll3 on coll3.CollectionID=collcoll2.parentCollectionID
left join v_CollectToSubCollect collcoll3 on collcoll3.SubCollectionID=coll3.CollectionID
left join v_Collection coll4 on coll4.CollectionID=collcoll3.parentCollectionID
left join v_CollectToSubCollect collcoll4 on collcoll4.SubCollectionID=coll4.CollectionID
left join v_Collection coll5 on coll5.CollectionID=collcoll4.parentCollectionID
left join v_CollectToSubCollect collcoll5 on collcoll5.SubCollectionID=coll5.CollectionID
left join v_Collection coll6 on coll6.CollectionID=collcoll5.parentCollectionID
left join v_CollectToSubCollect collcoll6 on collcoll6.SubCollectionID=coll6.CollectionID
left join v_Collection coll7 on coll7.CollectionID=collcoll6.parentCollectionID
left join v_CollectToSubCollect collcoll7 on collcoll7.SubCollectionID=coll7.CollectionID
left join v_Collection coll8 on coll8.CollectionID=collcoll7.parentCollectionID
left join v_CollectToSubCollect collcoll8 on collcoll8.SubCollectionID=coll8.CollectionID
left join v_Collection coll9 on coll9.CollectionID=collcoll8.parentCollectionID
left join v_CollectToSubCollect collcoll9 on collcoll9.SubCollectionID=coll9.CollectionID
order by Path

Wenn jemand eine einfachere Lösung weiß, so darf er sie mir gern mitteilen…
Wenn im Report “(ERROR: Not Linked)” angezeigt wird, wurde eine Collection von SMS/SCCM nicht ordentlich gelöscht. Um das Löschen zu wiederholen, muss sie zunächst wieder irgendwohin gelinkt werden. Ich erledige das mit einem Skript, das die angegebene Collection wieder auf die RootCollection linkt:

Link2CollRoot.vbs


' ******************************************************
' File: Link2CollRoot.vbs
' Version: 1.0
' Author: Thorsten Lau
' *****************************************************

' This script links a given collection to the root collection.
' This is helpful, if you can't find it linked elsewhere.

Dim objSWbemLocator
Dim objSWbemServices
Dim objSWbemContext
Dim ProviderLoc
Dim Location
Dim CollID
Dim subCollection
Dim newCollectionRelation

'specify your server name here, if it is remote
server = "."

CollID = InputBox ("Please enter the collection ID to be linked to Root:", "Link2CollRoot")

If CollID = "" Then
msgbox "Canceled", vbOKOnly+vbCritical, "Link2CollRoot"
WScript.Quit(1)
ElseIf UCASE(CollID) = "COLLROOT" Then
msgbox "Canceled. Cannot link Root Collection.", vbOKOnly+vbCritical, "Link2CollRoot"
WScript.Quit(1)
End If

'Connect to provider namespace for local computer.
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

Set objSWbemServices= objSWbemLocator.ConnectServer(server, "rootsms")

Set ProviderLoc = objSWbemServices.InstancesOf("SMS_ProviderLocation")

For Each Location In ProviderLoc
If Location.ProviderForLocalSite = True Then
Set objSWbemServices = objSWbemLocator.ConnectServer _
(Location.Machine, "rootsmssite_" + Location.SiteCode)
End If
Next

'Get the collection.
Set subCollection = objSWbemServices.Get("SMS_Collection.CollectionID='"&CollID&"'")

'Create the collection relationship.
'You could use the VerifyNoLoops method of the SMS_Collection class
'if you want to ensure that you won't create a loop of collections.
Set newCollectionRelation = objSWbemServices.Get( "SMS_CollectToSubCollect" ).SpawnInstance_()
newCollectionRelation.parentCollectionID = "COLLROOT"
newCollectionRelation.subCollectionID = subCollection.CollectionID
newCollectionRelation.Put_

msgbox subCollection.Name & " successfully linked", vbOKOnly+vbInformation, "Link2CollRoot"

Kommentarfunktion ist deaktiviert