Setting up the System Center Configuration Manager environment
This section talks about how to setup your Windows PowerShell console to start with the SCCM activities. The traditional method of importing the SCCM module in Windows PowerShell is supported by SCCM 2007 and its later versions.
The prerequisites to set up SCCM are as follows:
- SCCM 2007 or its later version infrastructure
- Windows PowerShell 2.0 or its later version
Connecting to Windows PowerShell for SCCM
The steps for connecting to Windows PowerShell for SCCM are as follows:
- Start the 32-bit Windows PowerShell console from your operating system box, as the SCCM infrastructure is only supported with the 32-bit PowerShell architecture.
- If you are using Windows Server 2008 R2 or a similar operating system, then you can click on Start, search for Windows PowerShell (x86), and launch the console.
If you are using Windows Server 2012 or a similar operating system, then you can press the Windows key + F, search for Windows PowerShell, and choose Apps in the console. From the search list, select Windows PowerShell (x86) and launch the console.
- To import the Configuration Manager PowerShell module, we need to change the console location to the
Configuration Manager Installation
folder. For example, we will refer to the parent installation folder asC:\Program Files(x86)
. - Type the following lines into the PowerShell console:
PS C :\> cd "C:\Program Files(x86)\Microsoft Configuration Manager\AdminConsole\bin"
This will set the console location to the
bin
subfolder in theConfiguration Manager Installation
folder. - Now, import the
ConfigurationManger.psd1
module file by using theImport-Module
cmdlet:PS C :\> Import-Module .\ConfigurationManager.psd1
Note
To confirm the successful import of the module, you can type
Get-Module CMDLET
in the PowerShell console. Now you will be able to see the new module added to the ConfigurationManager list. - After successfully importing the module file, set the console location to your site location by using your site code. For example, we have taken ABC site code in the following command statement:
PS C :\> Set-Location ABC:
The Configuration Manager PowerShell module also includes PowerShell Driver Provider for Configuration Manager Sites. For example, if you have a central site administration, site
ABC
and two primary sitesPS1
andPS2
, then you can change the connection context like this:PS C :\> Set-Location ABC: PS C :\> Set-Location PS1: PS C :\> Set-Location PS2:
Note
If you don't change the connection context, then you can't manage the Configuration Manager Site as well.
- Now you are ready to manage your Configuration Manager infrastructure using Windows PowerShell.
Tip
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
There is also another simple method available to connect SCCM using PowerShell with the latest releases of SCCM 2012 and so on. The prerequisites for that are as follows:
- System Center Configuration Manager 2012 SP1 RTM or a later version infrastructure
- Windows Server 2012 or Windows Server 2008 R2 with WMF 3.0
Connecting to Windows PowerShell from the SCCM console
The steps for connecting to Windows PowerShell from the SCCM console are as follows:
- Press the Windows key + F, search for Configuration Manager, and choose Apps. From the search list, select Configuration Manager Console and launch the console.
- In the Configuration Manager Console, click on the upper-left corner of the console and select Connect via Windows PowerShell.
- The Configuration Manager then imports the PowerShell module automatically.
- Now you are ready to manage your Configuration Manager infrastructure using the Windows PowerShell console.