Starting from ConfigMgr 2012 R2 we can use New-Item PowerShell cmdlet to create ConfigMgr Admin Console folders. Here is one simple and quick PowerShell script that allows you to create folders and Collections and finally it moves the Collection to correct folder.
#Step 1 Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location "$($SiteCode.Name):\" #Step 2 New-Item -Name 'OSD' -Path 'PS1:\DeviceCollection' New-Item -Name 'Mobile Device Management' -Path 'PS1:\DeviceCollection' New-Item -Name 'Power Management' -Path 'PS1:\DeviceCollection' New-Item -Name 'ViaMonstra' -Path 'PS1:\DeviceCollection' New-Item -Name 'Software Updates' -Path 'PS1:\DeviceCollection' New-Item -Name 'Compliance' -Path 'PS1:\DeviceCollection' #Step 3 New-CMDeviceCollection -Name 'Test 1' -LimitingCollectionName 'All Systems' New-CMDeviceCollection -Name 'Test 2' -LimitingCollectionName 'All Systems' New-CMDeviceCollection -Name 'Test 3' -LimitingCollectionName 'All Systems' New-CMDeviceCollection -Name 'Test 4' -LimitingCollectionName 'All Systems' New-CMDeviceCollection -Name 'Test 5' -LimitingCollectionName 'All Systems' #Step 4 $Collection1 = Get-CMDeviceCollection -Name 'Test 1' $Collection2 = Get-CMDeviceCollection -Name 'Test 2' $Collection3 = Get-CMDeviceCollection -Name 'Test 3' $Collection4 = Get-CMDeviceCollection -Name 'Test 4' $Collection5 = Get-CMDeviceCollection -Name 'Test 5' #Step 5 Move-CMObject -InputObject $Collection1 -FolderPath 'PS1:\DeviceCollection\OSD' Move-CMObject -InputObject $Collection2 -FolderPath 'PS1:\DeviceCollection\Mobile Device Management' Move-CMObject -InputObject $Collection3 -FolderPath 'PS1:\DeviceCollection\Power Management' Move-CMObject -InputObject $Collection4 -FolderPath 'PS1:\DeviceCollection\ViaMonstra' Move-CMObject -InputObject $Collection5 -FolderPath 'PS1:\DeviceCollection\Software Updates'
After the script execution you have 6 folders and in each folder Test x Collection – as you see it is really easy to create Collections and Folders with PowerShell.
Best,
Kaido
Ciao Kaido,
thanks for the basics. Wouldn’t it be a better way to switch the ‘PS1’
New-Item -Name ‘OSD’ -Path ‘PS1:DeviceCollection’
with the $SiteCode?
New-Item -Name ‘OSD’ -Path $SiteCode’:DeviceCollection’
It could be used for any environment no matter what the Site Code is.. ?
Cheers,
Alex
Yes Alex, It is much better idea to use variables and make it dynamic.
For this post my idea was to keep it simple and we even don´t need the Site Code:
New-Item -Name TEST2 -Path .DeviceCollection
or using the variable like this
New-Item -Name TEST3 -Path “$($Sitecode.Name):DeviceCollection”
Best,
Kaido
[…] et des collections au sein de la console SCCM 2012 R2. Vous pouvez retrouver le script ici: http://blog.coretech.dk/kaj/create-configmgr-collections-and-admin-console-folders-with-powershell/ Facebook Like (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if […]
How do you delete an folder in sccm?? under PRI:\DeviceCollection