SCCM - Delete devices collections with no members and no deployments

This script will detect and delete SCCM Collections that have no members and no deployment assigned to it.This can be useful to delete unused/unneeded collections. The script will detect the targeted collectionsThe script will prompt the user for a confirmation before each delet

 
 
 
 
 
4.8 Star
(4)
1,112 times
Add to favorites
System Center
9/1/2017
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • prompt SiteCode when more than one PSDrive found
    2 Posts | Last post September 05, 2017
    • Hi Benoit and thank you for sharing ! Just a thought :
      the first time I ran the script, I get this error "Get-CmCollection : This command cannot be run from the current drive. To run this command you must first connect to a Configuration Manager drive." .
      What was happening is I had 2 CMSITE psdrive (one connected on production server and another to a test server) and $SiteCode = Get-PSDrive -PSProvider CMSITE produce a wrong code ( PP1 PR1), maybe you could add a prompt to choose the correct drive in that case ?
    • Hi Loic,
      
      Good catch, I will try to make adjustments in the next version.
      
      Thank you for your suggestion.