Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (26 sloc) 996 Bytes
function Get-CMModule
#This application gets the configMgr module
[Parameter(HelpMessage = "Enter the Site Code you would like to connect to" )]
[string]$SiteCode = "YOURSITECODEHERE",
[Parameter(HelpMessage = "Enter the name of the site server you would like to connect to")]
[string]$SiteServer = "YOURSITESERVERHERE"
Write-Verbose "Attempting to import SCCM Module"
#Retrieves the fcnction from ConfigMgr installation path.
Import-Module (Join-Path $(Split-Path $ENV:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1) -Verbose:$false
Write-Verbose "Succesfully imported the SCCM Module"
$initParams = @{}
if($null -eq (Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue)) {
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $SiteServer @initParams
Throw "Failure to import SCCM Cmdlets."
You can’t perform that action at this time.