When working with ConfigMgr and PowerShell you’ll need to interact with folders.
- Get folder
- Create folder
- Delete folder
Pre ConfigMgr 2111
The folder structure can be accessed using the site code as a PSDrive. For example, PS1:\.
Each workspace and node have different folder structures within them. To see the options use the command below.
The folder structure used in PowerShell doesn’t always match the folder structure in the console. Generally, the console shows the items using the plural of the word, while PowerShell uses the singular of the word. In the console it’s Applications, while in PowerShell it’s Application.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
get-item PS1:\* Application BootImage ConfigurationBaseline ConfigurationItem DeviceCollection Driver DriverPackage OperatingSystemImage OperatingSystemInstaller Package Query SoftwareMetering SoftwareUpdate TaskSequence UserCollection UserStateMigration VirtualHardDisk SmsProvider |
List folders
To list a folder use the following:
1 2 3 4 5 6 |
Get-Item PS1:\Application\* | select Name Name ---- PatchMyPC Test |
Create folder
To create a folder use the following:
1 |
New-Item PS1:\Application\SuperCoolApplications |
Remove folder
To remove a folder use the following:
1 |
remove-item PS1:\Application\SuperCoolApplications |
Post ConfigMgr 2111
ConfigMgr added four new cmdlets to deal with folders:
1 2 3 4 |
Get-CMFolder New-CMFolder Remove-CMFolder Set-CMFolder |
To be continued…