Posts Tagged ‘Powershell’

Powershell for ConfigMgr 2012 – part 1 (introduction)

August 9, 2013

ConfigMgr 2012 comes with a lot of powershell cmdlets to make your life easier.

Since SP1, a whopping 471 of them even!

But how do we access them? There is no shortcut called “PowerShell for ConfigMgr” placed on your desktop after installation of ConfigMgr, we have to do some work for that ourselves.

How to:

First, start the x86 version of Powershell (run as admin).

Image

Since the ConfigMgr Console is 32-bit still, and the powershell cmdlets come with the console, they are also 32-bits.

Then in powershell type: cd “C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin” to get to the proper folder where the ConfigMgr Powershell module is located.

Image

Then we type Import-Module .\ConfigurationManager.psd1 to load the powershell module for Configuration Manager, making all the CmdLets available to us.

Image

Now we can start running the cmdlets. But which are they, and what can we do with them?

For that, let’s first update the help files. Make sure your machine has internet connectivity, so the updated help files can be downloaded from Microsoft;

Type Update-Help

After the help-updates have been downloaded, let’s see which cmdlets we have now for Configuration Manager.

Type get-command -module ConfigurationManager | out-gridview

This will show a nice list of all available ConfigMgr Cmdlets

Image

For a complete list of all the CmdLets, including a brief description of their function click here

You can get more info for each CmdLet by typing get-help <cmdlet>

For instance: get-help Add-CmDeploymentType

Now, we can also launch the PowerShell CmdLets from the ConfigMgr Admin Console!

However, it is very will hidden in my opinion.  Ever seen the little blue arrow on the top-left of the console?

Image

 

Whoomp, there it is. A x86 Powershell session, started as admin.

Type Y to allow the execution of the script, and off you go.

Capture6

In the next post, i will discuss some common useful Cmdlets, to create collections and such.

 

Advertisements