SMS SQL for Duplicate Collection Names

Recently, I've found many collections with duplicate names. The dupes can cause problems when managing those collections. I quickly created the following SQL to find the offending collections.

-- This SQL query will show collections with duplicate names.

Select parentCollectionID, ParentCollection.Name, v_Collection.CollectionID, v_Collection.Name from v_Collection
left outer join
v_CollectToSubCollect
on v_Collection.collectionid=v_CollectToSubCollect.subcollectionid
left outer join
v_Collection ParentCollection
on v_CollectToSubCollect.parentCollectionID = ParentCollection.collectionid
where v_Collection.Name in (Select Name from v_Collection Group By Name Having Count(*)>1)

About the Author

Emmanuel Tsouris is a Systems Management veteran and Developer Advocate specializing in PowerShell and Cloud Automation. He maintains DotVBS to preserve legacy knowledge for the "archaeologist admin."

Ready to move from VBScript to the Cloud? Check out his book, Pro PowerShell for Amazon Web Services.

Visit EmmanuelTsouris.com for his latest projects.

As an Amazon Associate, I earn from qualifying purchases at no cost to you.

Comments

Popular posts from this blog

SMS "Program failed (run time exceeded)" 10070

SMS "Waiting for User Condition" 10036

Reading the SCCM Client GUID