Howto – Connect to Configuration Manager 2012 from Powershell

Hi, Emil here. Have you ever wonder howto connect to a configuration manager 2012 site from Powershell? Okay, follow the steps below to success:

Requirements:

  • SCCM 2012 Console
  • Powershell 3.0
  • Be a member of SCCM Site Administrators group

1. Install Required Stuff and add you to Sccm Site Admin group.

After you have installed you required stuff like Powershell 3.0 and SCCM 2012 Console on your client or server, you are ready to go to next steps.

2. Start the builtin Windows PowerShell Integrated Scripting Environment (ISE) as a SCCM-Site-administrator.

3. Load the Configuration Manager Module. Type and run following Line:

Import-Module ((Split-Path $env:SMS_ADMIN_UI_PATH) + "\ConfigurationManager.psd1")

4. After you imported the ConfigMgr Module. Now you can go to that psdrive with following line:

Set-Location -Path ((Get-PSDrive -PSProvider CMSite).Name + ":\")

5. Now you are ready to do some rocken roll with your Sccm Site. ex: Try following line, to see all cmdlets for Configuration Manager 2012.

Get-Command -Module ConfigurationManager

Isn’t that cool?

And Here some cool script you can put at beginning of your script, to validate if the configMgr Module is loaded or not. If not loaded – load the module. Else go to cmSite Drive.

# Load the Configuration Manager Module.</pre>
<code> If (!(Get-Module -Name ConfigurationManager))
{
Import-Module ((Split-Path $env:SMS_ADMIN_UI_PATH) + "\ConfigurationManager.psd1")
Set-Location -Path ((Get-PSDrive -PSProvider CMSite).Name + ":\")
}
else
{
Set-Location -Path ((Get-PSDrive -PSProvider CMSite).Name + ":\")
} # End Of script - Load the Configuration Manager Module.</code>


Lämna ett svar

E-postadressen publiceras inte. Obligatoriska fält är märkta *

Dagens boktips!

Mastering System Center 2012 Configuration Manager (SCCM) The latest version of System Center Configuration Manager (SCCM) is a dramatic update of its predecessor Configuration Manager 2007, and this book offers

Köra Kommandotolken som system-konto

Här kommer lite information och tips hur man går tillväga att testa applikationer som system-konto. 1. Ladda hem verktyg PSTOOLS och packa upp till en mapp – http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx 2. Ta PSTOOLS mappen

Howto – Enable Powershell Remoteing in Windows Domain

Here comes some instructions, howto Enable Powershell Remoting in a Windows Domain. Step 1 – Set Powershell Execute Policy: By Default the powershell allow only code-signed powershell script. To be