Manage ConfigMgr Organizational Folders with PowerShell

This code is designed to create the organizational folders for Device Collections in Chapter 5 of “Learn ConfigMgr 2012 in a Month of Lunches“.

Because we’re creating multiple folders of the same type all at once, I chose to create a new array called $Folders, and then loop the creation command through each entry in the array.  If you want to create a single folder, obviously you don’t need to build an array to do this.

The ObjectType parameter determines what kind of organizational folder you are going to create.  For a full list of ObjectType options, check out this article by Kaido Järvemets (which is also where I borrowed the code for the creation section in the ForEach loop).


# Define Configuration Manager variables
$CMSiteCode = 'P01'
$CMSiteServer = ''
$CMNameSpace = "rootSMSsite_$CMSiteCode"
# 1.0 Create array of names for Folders
$Folders = @()
$Folders += 'Application Deployment'
$Folders += 'Operating System Deployment'
$Folders += 'Software Update Deployment'
# 1.1 Create a folder for each name in the array
foreach ($Folder in $Folders){
  $Arguments = @{Name = $Folder; ObjectType = 5000; ParentContainerNodeId = 0}
  Set-WmiInstance -ComputerName $CMSiteServer -Namespace $CMNameSpace -Class SMS_ObjectContainerNode -Arguments $Arguments
# Tip - you may need to close and re-open the Configuration Manager console to see the changes


2 comments to Manage ConfigMgr Organizational Folders with PowerShell

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>