Powershell Import-Modules for Orchestrator

This is just a quick post to use as a reference for when writing powershell scripts for orchestrator. I will update this post in the future with other useful Import-Module powershell snippets as I write them or run across them in my runbooks.

The snippets that don’t say Remote connection next to them you need to have the powershell Cmdlets installed locally on your Orchestrator Server.

Exchange – Remote Connection

$PassUnsecure = “<password>”

$Pass = ConvertTo-SecureString $PassUnsecure -AsPlainText -Force

$Cred = New-Object -TypeName system.management.automation.PSCredential (“<username>”, $Pass)

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://&lt; ServerName>/powershell/ -Credential $Cred -Authentication Kerberos -AllowRedirection

Import-PSSession $Session

Config Mgr

$sitecode = “<siteCode>:”

$installdrive = “C:”

IF(test-path ($installdrive + “\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin”)) {

Import-Module ($installdrive + “\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1”)



{IF(test-path ($installdrive + “\Program Files\Microsoft Configuration Manager\AdminConsole\bin”)){

Import-Module ($installdrive + “\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1”)




Write-host -Message “ConfigMgr 2012 powershell module not found!” -severity 1 -component “Error”



Set-Location $sitecode


Import-Module OperationsManager

New-SCOMManagementGroupConnection -ComputerName <servername>

Lync – Remote Connection

#Service account

$RunAsAccount = “<username>”

$RunAsPass = “<password>”

$pass = $RunAsPass | ConvertTo-SecureString -AsPlainText -Force

$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $RunAsAccount, $pass

# connection URI needs to point to the Lync Server, This Creates a remote PS session to Lync and loads the cmdlets

$s = New-PSSession -ConnectionUri https:// <FDQN>/OcsPowershell -Credential $credentials

Import-PSSession $S

This entry was posted in ConfigMgr, Exchange, Lync, OpsMgr, Powershell, SCORCH and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s