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 *

Wsus Post-configuration fails on Windows Server 2012 Sp1 with SQL Server 2012 Sp1

Hi! I got some problem when I tried to install Windows Server Update Services on my Test Windows Server 2012 Sp1 with SQL Server 2012 Sp1 installed. The Role installation

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

SCCM 2012 R2 Quiz

Hur mycket kan du om SCCM 2012 R2? Microsoft System Center Configuration Manager Product Group har skapat en Quiz-applikation där du kan testa dina kunskaper om olika nyheter och funktioner