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 *

404 Server Error on CMApplicationCatalog – SCCM 2012

When you install “Application Catalog web service point” and “Application Catalog website point” in SCCM 2012 you get 404 Error when browsing http://SCCMserver/CMApplicationCatalog. To fix this you need to enable/activate

ERROR: Failed to get SID for user (NT Service\MSSQLSERVER)

During the installation of the new System Center Configuration Manager 2012 with Microsoft SQL Server 2012 I got the following error and the installtion couldn´t continue. ERROR: Failed to get

Prompt for Computer Name during OSD in Task Sequence with Powershell GUI

1) Download the Script. Change the file extension from txt to ps1 and save it to networkshare. The GUI is created with Sapien Powershell Studio 2) Create a package in