Ying Li at myITforum.com

PowerShell & System Center

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 {$_.name -match "mbx"}

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


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!


subject: exchange said:

How-to: Connect your Windows Mobile device to an Exchange server (WM5) Microsoft Publicly Posts Additional

# April 11, 2008 12:49 PM

Ying Li at myITforum.com said:

Here is a PowerShell script to install SCOM agent on multiple servers. In my previous blog Re-Uniting

# May 15, 2008 7:15 PM