Share This Post

Re-Uniting PowerShell Consoles on your Computer

I have Exchange 2007 Administrator tool and SCOM administrator tool installed on my computer. Both come with a GUI console and a PowerShell console. On top of that, I have my regular PowerShell console.

Before I have to juggle between these three PS consoles to accomplish different daily tasks. Well, not any more!

Go to Start – All Programs – Windows PowerShell v2(CTP) – right click on Windows PowerShell v2(CTP)– Windows PowerShell v2(CTP)Properties -Target, here is what’s there


Do the similar thing for SCOM 2007 and Exchange 2007, you get below text respectively:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Console.psc1 -NoExit .\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Startup.ps1

C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -noexit -command ". ‘C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1’"

As you can see, there nothing more special about SCOM and Exchange – They are using the same PowerShell console (PowerShell.exe) except they add their console file respectively. Console files are xml files with psc1 extensions, they store configuration setting for their application specific consoles.

Here is how I use one console to do all my jobs:

Start the regular PowerShell Console

PS C:\Documents and Settings\yl.admin\My Documents\PS>

I then run addExSnapin.ps1 script which has only one line in it –

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

PS C:\Documents and Settings\yl.admin\MyDocuments\PS> .\AddExSnapin.ps1

I go back to the same prompt except now I can run Exchange cmdlets

PS C:\Documents and Settings\yl.admin\My Documents\PS> Get-MailboxDatabase

Name Server StorageGroup Recovery
—- —— ———— ——–
CES01 SG01 DB xyz01 CES01 SG01 False
CES01 SG02 DB xyz01 CES01 SG02 False



I then run a script AddConnSCOMSnapin.ps1:

Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"
Set-Location "OperationsManagerMonitoring::"
$rootMS = "XYZOPMP01"
new-managementGroupConnection -ConnectionString:$rootMS
Set-Location $rootMS

PS C:\Documents and Settings\yl.admin\My Documents\PS> .\AddConnSCOMSnapin.ps1

PathName :
ManagementGroup : XYZ Enterprise Apps
ManagementServerName : XYZOPMP01
Drives :

PS Microsoft.EnterpriseManagement.OperationsManager.Client\OperationsManagerMonitoring::XYZOPMP01> get-agent| where-obj
ect {$ -match "mbx"}

PrimaryManagementServerName :
Id : 3e8e5503-3437-22d3-669f-2209b8a71694
LastModified : 4/7/2008 10:41:50 PM
Name :
DisplayName :
HostComputer :
HostedHealthService :
HealthState : Error
PrincipalName :
NetworkName :
ComputerName :


If I want swich back?

PS Microsoft.EnterpriseManagement.OperationsManager.Client\OperationsManagerMonitoring::XYZOPMP01> cd "C:\Documents and
Settings\yl.admin\My Documents\PS"
PS C:\Documents and Settings\yl.admin\My Documents\PS>

Whoa, now I can use one PS console and easily swich back and forth between all my daily administration tasks!

Share This Post

Ying Li obtained a Master degree of Medicine in China and worked in the medical field before he came to the states in 1996. He made the career switch from troubleshooting people to troubleshooting computers after he came to the states. Not entirely a surprise there, if you know that his second preference for college is Mathematics. Ying is two times Admin Framework MVP awardee (2007-2008).His previous employment experience in the US includes UUNET, MCI WorldCom. MMC (Marsh & McLennan Companies), Merrill Lynch. He is currently employed by Related Companies as a Senior Infrastructure Engineer. He is proficient in virtually all Microsoft products (Office/Back office). His craving for efficiency naturally leads him to scripting, automation and before you know it, PowerShell! He is currently a MCSE (NT4, 2000, 2003) and MCITP Server Administrator. Ying enjoys wines and love to travel. His non work related passion is to advocate Health Living!

Leave a Reply