{"id":78,"date":"2007-02-21T16:21:07","date_gmt":"2007-02-22T00:21:07","guid":{"rendered":"http:\/\/testblog.sapien.com\/index.php\/2007\/02\/21\/managing-exchange-2003-servers-with-powershell\/"},"modified":"2007-02-21T16:21:07","modified_gmt":"2007-02-22T00:21:07","slug":"managing-exchange-2003-servers-with-powershell","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2007\/02\/21\/managing-exchange-2003-servers-with-powershell\/","title":{"rendered":"Managing Exchange 2003 Servers with PowerShell"},"content":{"rendered":"<p>We all know that PowerShell and Exchange 2007 were made for one another.&nbsp; However, that doesn&#8217;t mean you can&#8217;t use PowerShell to manage Exchange 2003 servers. I&#8217;m not saying you can get all the functionality that you do with Exchange 2007, but you&#8217;re not totally left out either.&nbsp; Exchange 2003 added many WMI classes and the Get-WMIObject cmdlet is perfect for getting information from Exchange 2003.&nbsp; In fact, because of pipelining, it is even easier to get information properly formatted than it is using VBScript.<\/p>\n<p>The first thing to note is that instead of connecting to the default root\\cimv2 namespace, you need to connect to root\\MicrosoftExchangeV2.&nbsp; Here&#8217;s a simple PowerShell expression you can run:<\/p>\n<p><font face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-Wmiobject -query <span class=\"str\">&#8220;Select * from Exchange_Server&#8221;<\/span> &#8211;<span class=\"kwrd\">namespace<\/span> root\\MicrosoftExchangeV2 -computer TANK<\/font>  <\/p>\n<p>This code was executed from a another server in the domain connecting to the Exchange 2003 server, TANK.&nbsp; This is the output I got back:&nbsp;&nbsp;  <\/p>\n<p><font size=\"2\" face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">__GENUS : 2 <br \/>__CLASS : Exchange_Server <br \/>__SUPERCLASS : CIM_LogicalElement <br \/>__DYNASTY : CIM_ManagedSystemElement <br \/>__RELPATH : Exchange_Server.FQDN=<span class=\"str\">&#8220;TANK.matrix.local&#8221;<\/span> <br \/>__PROPERTY_COUNT : 22 <br \/>__DERIVATION : {CIM_LogicalElement, CIM_ManagedSystemElement} <br \/>__SERVER : TANK <br \/>__NAMESPACE : root\\MicrosoftExchangeV2 <br \/>__PATH : &#92;TANK\\root\\MicrosoftExchangeV2:Exchange_Server.FQDN=&#8221;TANK.matrix. AdministrativeGroup : First Administrative Group <br \/>AdministrativeNote : <br \/>Caption : <br \/>CreationTime : 20041201202912.000000+000 <br \/>Description : <br \/>DN : CN=TANK,CN=Servers,CN=First Administrative Group,CN=Administrative =Microsoft Exchange,CN=Services,CN=Configuration,DC=matrix,DC=local ExchangeVersion : Version 6.5 (Build 7638.2: Service Pack 2) <br \/>FQDN : TANK.matrix.local <br \/>GUID : {9B9A3518-49AF-463D-9FAD-635CD8F60F10} <br \/>InstallDate : <br \/>IsFrontEndServer : <span class=\"kwrd\">False<\/span> <br \/>LastModificationTime : 20051101214324.000000+000 <br \/>MessageTrackingEnabled : <span class=\"kwrd\">False<\/span> <br \/>MessageTrackingLogFileLifetime : 0 <br \/>MessageTrackingLogFilePath : C:\\Program Files\\Exchsrvr\\TANK.log MonitoringEnabled : <span class=\"kwrd\">True<\/span> <br \/>MTADataPath : C:\\Program Files\\Exchsrvr\\mtadata <br \/>Name : TANK <br \/>RoutingGroup : First Routing Group <br \/>Status : <br \/>SubjectLoggingEnabled : <span class=\"kwrd\">True<\/span> <br \/>Type : 1<\/font> <\/p>\n<p>Pretty handy don&#8217;t you think?&nbsp; But I have to say I like using PowerShell for this sort of thing even better than VBScript. With PowerShell I can take the results of my WMI query, sort, select and format all in a single expression.&nbsp; Ever wonder who the top 10 mailbox &#8220;offenders&#8221; are on your Exchange server?&nbsp; Try this:<\/p>\n<p><font size=\"2\" face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-Wmiobject &#8211;<span class=\"kwrd\">namespace<\/span> root\\MicrosoftExchangeV2 &#8211;<span class=\"kwrd\">class<\/span> Exchange_Mailbox -computer TANK ` | sort -desc size | select `<br \/>StorageGroupName,StoreName,MailboxDisplayName,Size,TotalItems -first 10&nbsp;<\/font><\/p>\n<p>And this is the report I get:  <font face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\"><\/p>\n<pre>StorageGroupName     StoreName            MailboxDisplayName Size TotalItems<br \/>----------------     ---------            ------------------ ---- ----------<br \/>Second Storage Group Sales Mailboxes      Barb Zpuutwoko     2691         77<br \/>Second Storage Group Sales Mailboxes      Barb Zemnyzdpg     2691         77<br \/>Second Storage Group Sales Mailboxes      Barb Yzdpmbctwf    2691         77<br \/>Second Storage Group Sales Mailboxes      Barb Ksuvrel       2690         77<br \/>Second Storage Group Sales Mailboxes      Barb Pks           2687         77<br \/>First Storage Group  Mailbox Store (TANK) Administrator      2595         31<br \/>First Storage Group  Mailbox Store (TANK) Charlie Brown      1667         94<br \/>First Storage Group  Beta Mail            Ellen Rkobymnenr   1081         81<br \/>First Storage Group  Beta Mail            Ellen Sdoadbhjrb   1081         81<br \/>First Storage Group  Beta Mail            Ellen Vlgplgntk    1080         81<\/pre>\n<p><\/font><\/p>\n<p>I&#8217;ll explore some other things we can do with PowerShell and Exchange 2003 in future posts.&nbsp;&nbsp;<\/p>\n<div style=\"margin: 0px; padding: 0px; display: inline;\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:c425e378-1c2f-45ed-8bf6-b5cc1e313a27\" class=\"wlWriterSmartContent\">Technorati tags: <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/PowerShell\">PowerShell<\/a>, <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/Exchange2003\">Exchange2003<\/a>, <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/WMI\">WMI<\/a>, <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/Scripting\">Scripting<\/a><\/div>\n<p><\/p>\n<div style=\"margin: 0px; padding: 0px; display: inline;\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:20150ef2-a0f5-4905-b1d4-af71c2eee594\" class=\"wlWriterSmartContent\">del.icio.us tags: <a rel=\"tag\" href=\"http:\/\/del.icio.us\/popular\/PowerShell\">PowerShell<\/a>, <a rel=\"tag\" href=\"http:\/\/del.icio.us\/popular\/scripting\">scripting<\/a>, <a rel=\"tag\" href=\"http:\/\/del.icio.us\/popular\/Exchange2003\">Exchange2003<\/a>, <a rel=\"tag\" href=\"http:\/\/del.icio.us\/popular\/WMI\">WMI<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We all know that PowerShell and Exchange 2007 were made for one another.  However, that doesn&#8217;t mean you can&#8217;t use PowerShell to manage Exchange 2003 servers. I&#8217;m not saying you can get all the functionality that you do with Exchange 2007, but you&#8217;re not totally left out either.  Exchange 2003 added many WMI classes and the Get-WMIObject cmdlet is perfect for getting information from Exchange 2003.  In fact, because of pipelining, it is even easier to get information properly formatted than it is using VBScript.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-windows-powershell"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=78"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/78\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}