PowerShell one-liners for Configuration Manager 2012

With Service Pack 1 you now have the option to use PowerShell against Configuration Manager. It comes with almost 500 cmdlets, which you can use.
And I planned that this post would be a live post where I am going to post all of my PowerShell one-liners for various tasks within Configuration Manager.
Now first of we need to import the module in order to get access to the cmdlets.

Import-module C:Program files (x86)Microsoft Configuration ManagerAdminConsoleBinConfigurationManager.psd1

after that we need to change context to the site name. In my case the site is called TST therefore I type
cd c:TST

NOTE: If you get any error messages here change to x86 PowerShell J
After you have done this you should look something like this.

Now a couple of commands first.
(Note that you can show all the cmdlets available either in PowerShell ISE or run the command

get-command –module ConfigurationManager

Install client on a device name.
Install-cmclient -AlwaysInstallClient $true -Devicename configmgr -IncludeDomainController $false -sitecode TST

You can also specify it by deviceID.
Install-CMClient -AlwaysInstallClient $True -DeviceId 16777220 -IncludeDomainController $False -SiteCode TST

If you want to fetch the deviceID or get more information regarding the device.
Get-CMDevice -Name configmgr

Get information regarding a device collection
get-cmdevicecollection -Name “all systems”

If you want to export out the XML definition of a baseline

Get-CMBaselineXMLDefinition -name laptop | out-file C:testkonge2.xml

Wish to export an application
Export-CMApplication -name intune -path e:export.zip

If you wish to import an application
Import-CMApplication –path e:export.zip

Create a new client policy
New-CMClientSetting -name konge

And if you wish to add settings to that new policy
Set-CMClientSetting -Name konge -EnableEndpointProtection $True

Add a software metering rule
New-CMSoftwareMeteringRule -productname “Notepad” -path c:windowssystem32notepad.exe -SiteCode TST

Get software requests

There are a lot more to come, with this cmdlets it makes it a lot easier to automate deployment.

Leave a Reply

Scroll to Top