Exchange Demos with PowerShell - Basics
The first part of the demo I describe in my previous post was to introduce the crowd to the basics of interacting with the Exchange cmdlets in PowerShell:
[PS] C:\Documents and Settings\Administrator\Desktop>Get-ExchangeServer
Name Site ServerRole Edition AdminDisplayVersion
---- ---- ---------- ------- --------------
E12 Default-First-Sit... Mailbox,... Standard... Version 8.1...[PS] C:\Documents and Settings\Administrator\Desktop>$server = Get-ExchangeServer
[PS] C:\Documents and Settings\Administrator\Desktop>$serverName Site ServerRole Edition AdminDisplayVersion
---- ---- ---------- ------- --------------
E12 Default-First-Sit... Mailbox,... Standard... Version 8.1...[PS] C:\Documents and Settings\Administrator\Desktop>Get-StorageGroup
Name Server Replicated Recovery
---- ------ ---------- --------
First Storage Group E12 None False
Congress E12 None False[PS] C:\Documents and Settings\Administrator\Desktop>Get-MailboxDatabase
Name Server StorageGroup Recovery
---- ------ ------------ --------
Mailbox Database E12 First Storage Group False
House E12 Congress False
Senate E12 Congress False[PS] C:\Documents and Settings\Administrator\Desktop>get-mailbox
Name Alias ServerName ProhibitSendQuota
---- ----- ---------- ---------------
Administrator Administrator e12 unlimited
Daniel Akaka DaniAkaka e12 2100MB
Lamar Alexander LamaAlexander e12 2100MB
Wayne Allard WaynAllard e12 2100MB
### ** Cutting out a couple hundred more objects for brevity in the transcript file
Albert Wynn AlbeWynn e12 2100MB
C.W. Bill Young C.W.Young e12 2100MB
Don Young DonYoung e12 2100MB
exadmin exadmin e12 unlimited[PS] C:\Documents and Settings\Administrator\Desktop>get-mailbox | group database
Count Name Group
----- ---- -----
1 E12\First Storage Grou... {Administrator}
100 E12\Congress\Senate {Daniel Akaka, Lamar Alexander, Wayne Allard...
439 E12\Congress\House {Neil Abercrombie, Gary Ackerman, Robert Ade...[PS] C:\Documents and Settings\Administrator\Desktop>cd 'C:\Program Files\Microsoft\Exchange Server\Scripts\TR4'
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>New-DistributionGroup HomeLandComission -Type Distribution -SamAccountName HomeLandComission -OrganizationalUnit CongressName DisplayName GroupType PrimarySmtpAddress
---- ----------- --------- ------------------
HomeLandComission HomeLandComission Universal HomeLandComissio...[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-Content comission.txt
Susan Collins
Joseph Lieberman
Ted Stevens
Carl Levin
George Voinovich
Daniel Akaka
Norm Coleman
Thomas Carper
Tom Coburn
Mark Dayton
Lincoln Chafee
Frank Lautenberg
Robert Bennett
Mark Pryor
Pete Domenici
John Warner
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-Content comission.txt | Add-DistributionGroupMember Homelandcomission
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-DistributionGroupMember homelandc*Name RecipientType
---- -------------
Daniel Akaka UserMailbox
Robert Bennett UserMailbox
Thomas Carper UserMailbox
Lincoln Chafee UserMailbox
Tom Coburn UserMailbox
Norm Coleman UserMailbox
Susan Collins UserMailbox
Mark Dayton UserMailbox
Pete Domenici UserMailbox
Frank Lautenberg UserMailbox
Carl Levin UserMailbox
Joseph Lieberman UserMailbox
Mark Pryor UserMailbox
Ted Stevens UserMailbox
George Voinovich UserMailbox
John Warner UserMailbox[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-DistributionGroupMember homelandc* | get-mailbox
Name Alias ServerName ProhibitSendQuota
---- ----- ---------- ---------------
Daniel Akaka DaniAkaka e12 2100MB
Robert Bennett RobeBennett e12 2100MB
Thomas Carper ThomCarper e12 2100MB
Lincoln Chafee LincChafee e12 2100MB
Tom Coburn TomCoburn e12 2100MB
Norm Coleman NormColeman e12 2100MB
Susan Collins SusaCollins e12 2100MB
Mark Dayton MarkDayton e12 2100MB
Pete Domenici PeteDomenici e12 2100MB
Frank Lautenberg FranLautenberg e12 2100MB
Carl Levin CarlLevin e12 2100MB
Joseph Lieberman JoseLieberman e12 2100MB
Mark Pryor MarkPryor e12 2100MB
Ted Stevens TedStevens e12 2100MB
George Voinovich GeorVoinovich e12 2100MB
John Warner JohnWarner e12 2100MB[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-DistributionGroupMember homelandc* | get-mailbox | sort CustomAttribute3
Name Alias ServerName ProhibitSendQuota
---- ----- ---------- ---------------
Frank Lautenberg FranLautenberg e12 2100MB
Mark Dayton MarkDayton e12 2100MB
Carl Levin CarlLevin e12 2100MB
Mark Pryor MarkPryor e12 2100MB
Joseph Lieberman JoseLieberman e12 2100MB
Thomas Carper ThomCarper e12 2100MB
Daniel Akaka DaniAkaka e12 2100MB
Ted Stevens TedStevens e12 2100MB
Norm Coleman NormColeman e12 2100MB
John Warner JohnWarner e12 2100MB
George Voinovich GeorVoinovich e12 2100MB
Robert Bennett RobeBennett e12 2100MB
Pete Domenici PeteDomenici e12 2100MB
Tom Coburn TomCoburn e12 2100MB
Susan Collins SusaCollins e12 2100MB
Lincoln Chafee LincChafee e12 2100MB[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-DistributionGroupMember homelandc* | get-mailbox | sort CustomAttribute3 | Get-MailboxStatistics
DisplayName ItemCount StorageLimitStatus LastLogonTime
----------- --------- ------------------ -------------
Frank Lautenberg 6 BelowLimit
Mark Dayton 6 BelowLimit
Carl Levin 6 BelowLimit
Mark Pryor 6 BelowLimit
Joseph Lieberman 6 BelowLimit
Thomas Carper 6 BelowLimit
Daniel Akaka 9 BelowLimit
Ted Stevens 6 BelowLimit
Norm Coleman 6 BelowLimit
John Warner 6 BelowLimit
George Voinovich 6 BelowLimit
Robert Bennett 8 BelowLimit
Pete Domenici 6 BelowLimit
Tom Coburn 6 BelowLimit
Susan Collins 6 BelowLimit
Lincoln Chafee 6 BelowLimit[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-DistributionGroupMember homelandc* | get-mailbox | sort CustomAttribute3 | Get-MailboxStatistics | ./out-html
<!-- saved from url=(0014)about:internet --><html><head><title> Output Generate
d on: 2/7/2007 8:02:08 AM</title><style TYPE="text/css">
<style>
<!--
body { font: Helvetica }
table { font: 12pt Helvetica; border: 0px}
td { border: 1px solid lightgray; padding-left: 15px; padding-right: 15px }
p.header { font: 16pt Helvetica; color: DarkBlue }
p.normal { font: 14pt Helvetica; }
-->
</style>
</head>
<body>
<p class="header" align='center'><strong>Output Generated by Administrator at:
2/7/2007 8:02:08 AM on machine e12 </strong></p>
<p class='normal' align='center'><strong>Command line:</strong> Get-Distributio
nGroupMember homelandc* | get-mailbox | sort CustomAttribute3 | Get-MailboxStat
istics | ./out-html</p><br>
<table border="1" cellpadding="0" cellspacing="0" align="center">### ** Cutting out a couple pages of HTML for brevity in the transcript file
d align="Left"><p class="table"><b></b></p></td><td align="Left"><p class="tabl
e"><b>/O=FIRST ORGANIZATION/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/
CN=RECIPIENTS/CN=LINCCHAFEE1</b></p></td><td align="Left"><p class="table"><b>f
cf621ee-f60d-4b82-a889-e48ae7a4e7d5</b></p></td><td align="Left"><p class="tabl
e"><b>Mailbox</b></p></td><td align="Left"><p class="table"><b>e12.e12dom.local
</b></p></td><td align="Left"><p class="table"><b>E12</b></p></td><td align="Le
ft"><p class="table"><b>Congress</b></p></td><td align="Left"><p class="table">
<b>BelowLimit</b></p></td><td align="Left"><p class="table"><b>0B</b></p></td><
td align="Left"><p class="table"><b>670992B</b></p></td></tr>
</table><br>
</p></body></html>[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-DistributionGroupMember homelandc* | get-mailbox | sort CustomAttribute3 | Get-MailboxStatistics | ./out-html | ./out-ie
Application : System.__ComObject
Parent : System.__ComObject
Container :
Document : System.__ComObject
TopLevelContainer : True
Type : HTML Document
Left : 176
Top : 140
Width : 800
Height : 600
LocationName : https:///
LocationURL : https:///
Busy : False
Name : Microsoft Internet Explorer
HWND : 131294
FullName : C:\Program Files\Internet Explorer\iexplore.exe
Path : C:\Program Files\Internet Explorer\
Visible : True
StatusBar : True
StatusText :
ToolBar : 1
MenuBar : True
FullScreen : False
ReadyState : 3
Offline : False
Silent : False
RegisterAsBrowser : False
RegisterAsDropTarget : True
TheaterMode : False
AddressBar : True
Resizable : False[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-DistributionGroupMember homelandc* | get-mailbox | Group customattribute3
Count Name Group
----- ---- -----
7 D {Daniel Akaka, Thomas Carper, Mark Dayton, F...
9 R {Robert Bennett, Lincoln Chafee, Tom Coburn,...[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-DistributionGroupMember homelandc* | get-mailbox | Group customattribute3 | ./out-chart Name Count
In the next post, I'll cover the second part of the demo... calling .Net objects and introducing some of the PowerShell glue that makes manipulating Exchange data so powerful.
Comments
- Anonymous
January 01, 2003
How to: Install Exchange 2007 Management Tools for Windows Vista Look out BlackBerry, Palm is back Moving