Share via


Exchange Demos with PowerShell - Grand Finale/Provisioning

Continuing from the previous post, in this final part of the demo I explain how I provisioned the environment, and demonstrated a script to "rip out" the environment and then effortlessly "regenerate" it again:

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-MailboxDatabase | get-mailbox

Name Alias ServerName ProhibitSendQuota
---- ----- ---------- ---------------
Administrator Administrator e12 unlimited
Neil Abercrombie NeilAbercrombie e12 2100MB
Gary Ackerman GaryAckerman e12 2100MB
Robert Aderholt RobeAderholt e12 2100MB
Todd Akin ToddAkin e12 2100MB
### ** Cutting out a couple hundred more objects for brevity in the transcript file
David Vitter DaviVitter e12 2100MB
George Voinovich GeorVoinovich e12 2100MB
John Warner JohnWarner e12 2100MB
exadmin exadmin e12 unlimited

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-queue $server\Submission | get-message

Identity FromAddress Status Queue Subject
-------- ----------- ------ ----- -------
e12\Submissi... GaryAckerman... Ready e12\Submission Presenting M...
e12\Submissi... RickSantorum... Ready e12\Submission The Amendmen...
e12\Submissi... NeilAbercrom... Ready e12\Submission Senate Commi...
e12\Submissi... SusaCollins@... Ready e12\Submission Senate Actio...
e12\Submissi... KenSalazar@u... Ready e12\Submission Senate Actio...
e12\Submissi... HarrReid@usc... Ready e12\Submission Signatures o...
e12\Submissi... exadmin@usco... Ready e12\Submission Welcome

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-queue $server\Submission | get-message | group FromAddress

Count Name Group
----- ---- -----
1 GaryAckerman@uscongres... {SMTP:Client E12}
1 RickSantorum@uscongres... {SMTP:Client E12}
1 NeilAbercrombie@uscong... {SMTP:Client E12}
1 SusaCollins@uscongress... {SMTP:Client E12}
1 KenSalazar@uscongress.gov {SMTP:Client E12}
1 HarrReid@uscongress.gov {SMTP:Client E12}
1 exadmin@uscongress.gov {SMTP:Client E12}

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-queue $server\Submission | get-message | group FromAddress | sort count -Descending | select -First 3

Count Name Group
----- ---- -----
1 KenSalazar@uscongress.gov {SMTP:Client E12}
1 HarrReid@uscongress.gov {SMTP:Client E12}
1 exadmin@uscongress.gov {SMTP:Client E12}

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-queue $server\Submission | get-message | group FromAddress | Foreach { Get-MailboxStatistics $_.name }

DisplayName ItemCount StorageLimitStatus LastLogonTime
----------- --------- ------------------ -------------
Gary Ackerman 6 BelowLimit
Rick Santorum 6 BelowLimit
Neil Abercrombie 6 BelowLimit
Susan Collins 6 BelowLimit
Ken Salazar 6 BelowLimit
Harry Reid 6 BelowLimit
WARNING: There is no data to return for the specified mailbox
'exadmin@uscongress.gov', because it has not been logged on to.

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-mailbox j* | disable-mailbox

Confirm
Are you sure you want to perform this action?

Disabling Mailbox "e12dom.local/Congress/Joseph Biden" will remove the Exchange
properties from the Windows user object and mark the mailbox in the database
for removal.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):n

Confirm
Are you sure you want to perform this action?

Disabling Mailbox "e12dom.local/Congress/Jeff Bingaman" will remove the
Exchange properties from the Windows user object and mark the mailbox in the
database for removal.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):n

Confirm
Are you sure you want to perform this action?

Disabling Mailbox "e12dom.local/Congress/Jim Bunning" will remove the Exchange
properties from the Windows user object and mark the mailbox in the database
for removal.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-mailbox j* | disable-mailbox -whatif
What if: Disabling Mailbox "e12dom.local/Congress/Joseph Biden" will remove the Exchange properties from the Windows user object and mark the mailbox in the database for removal.
What if: Disabling Mailbox "e12dom.local/Congress/Jeff Bingaman" will remove the Exchange properties from the Windows user object and mark the mailbox in the database for removal.
What if: Disabling Mailbox "e12dom.local/Congress/Jim Bunning" will remove the Exchange properties from the Windows user object and mark the mailbox in the database for removal.
What if: Disabling Mailbox "e12dom.local/Congress/John Cornyn" will remove the Exchange properties from the Windows user object and mark the mailbox in the database for removal.
### ** Cutting out a bunch of objects for brevity in the transcript file
What if: Disabling Mailbox "e12dom.local/Congress/John Tierney" will remove the Exchange properties from the Windows user object and mark the mailbox in the database for removal.
What if: Disabling Mailbox "e12dom.local/Congress/Jim Walsh" will remove the Exchange properties from the Windows user object and mark the mailbox in the database for removal.
What if: Disabling Mailbox "e12dom.local/Congress/Jerry Weller" will remove the Exchange properties from the Windows user object and mark the mailbox in the database for removal.
What if: Disabling Mailbox "e12dom.local/Congress/Joe Wilson" will remove the Exchange properties from the Windows user object and mark the mailbox in the database for removal.

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-mailbox j* | disable-mailbox -Confirm:$false

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-MailboxStatistics -server $server | where { $_.Displayname -like "j*" }

DisplayName ItemCount StorageLimitStatus LastLogonTime
----------- --------- ------------------ -------------
Joe Baca 6
Julia Carson 3
Jerry Costello 3
John Campbell 5
John A. Boehner 6
J.Gresham Barrett 6
Jim Costa 3
Jim Cooper 3
Jo Bonner 6
John Boozman 6
Joseph Crowley 3
Joe Barton 6
Jo Ann S. Davis 3
Jim Davis 3
John Carter 3
Judy Biggert 6
John Conyers 3
John Barrow 6
John Culberson 3
James E. Clyburn 3
Jeb Bradley 6
Jeff Bingaman 7
Judd Gregg 6
James Jeffords 6
Jack Reed 6
Joseph Lieberman 6
John Rockefeller 6
John McCain 6
Joseph Biden 7
Johnny Isakson 6
John Sununu 6
John Ensign 6
John Cornyn 6
John Kerry 6
Jeff Sessions 6
James Talent 6
John Thune 6
John Warner 6
Jon Kyl 6
Jon Corzine 6
James Inhofe 6
Jim DeMint 6
Jim Bunning 7

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>Get-MailboxStatistics -server $server | where { $_.Displayname -like "j*" } | Connect-Mailbox

Confirm
Do you want to connect this mailbox to user "e12dom.local/Congress/Joe Baca"
with the alias "JoeBaca"?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):a
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>##### Grand Finale - removing all users and reprovisioning with scripts!
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>& 'C:\Program Files\Microsoft\Exchange Server\Scripts\TR4\cleanupcongress.ps1'
Removing users...
Removing email policy...
Removing databases on server E12 ...
WARNING: The specified database has been removed. You must remove the database
file located in C:\Program Files\Microsoft\Exchange
Server\Mailbox\Congress\House.edb from your computer manually if it exists.
Specified database: House
WARNING: The specified database has been removed. You must remove the database
file located in C:\Program Files\Microsoft\Exchange
Server\Mailbox\Congress\Senate.edb from your computer manually if it exists.
Specified database: Senate
WARNING: The specified storage group has been removed. You must remove the log
file located in C:\Program Files\Microsoft\Exchange Server\Mailbox\Congress
from your computer manually if it exists. Specified storage group:
E12\Congress.
Removing directory \\E12\C$\Program Files\Microsoft\Exchange Server\Mailbox\Congress ...
Done.
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-mailbox

Name Alias ServerName ProhibitSendQuota
---- ----- ---------- ---------------
Administrator Administrator e12 unlimited

[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>& 'C:\Program Files\Microsoft\Exchange Server\Scripts\TR4\generatecongress.ps1'
Creating OU ...
Creating databases...
Configuring email settings...
Creating mailboxes...

Name Alias RecipientType
---- ----- -------------
insider insider MailContact
Daniel Akaka
Lamar Alexander
### ** Cutting out a couple hundred more mailbox creations for brevity in the transcript file
Frank Wolf
Lynn Woolsey
David Wu
Albert Wynn
C.W. Bill Young
Don Young

Creating DLs...

GroupType : Universal
SamAccountName : Senate
ExpansionServer :
ReportToManagerEnabled : False
ReportToOriginatorEnabled : True
SendOofMessageToOriginatorEnabled : False
ManagedBy :
AcceptMessagesOnlyFrom : {}
AcceptMessagesOnlyFromDLMembers : {}
AddressListMembership : {Default Global Address List, All Groups}
Alias : Senate
OrganizationalUnit : e12dom.local/Congress
CustomAttribute1 :
CustomAttribute10 :
CustomAttribute11 :
CustomAttribute12 :
CustomAttribute13 :
CustomAttribute14 :
CustomAttribute15 :
CustomAttribute2 :
CustomAttribute3 :
CustomAttribute4 :
CustomAttribute5 :
CustomAttribute6 :
CustomAttribute7 :
CustomAttribute8 :
CustomAttribute9 :
DisplayName : Senate
EmailAddresses : {SMTP:Senate@e12dom.local}
GrantSendOnBehalfTo : {}
HiddenFromAddressListsEnabled : False
LegacyExchangeDN : /o=First Organization/ou=Exchange Administ
rative Group (FYDIBOHF23SPDLT)/cn=Recipien
ts/cn=Senate1
MaxSendSize : unlimited
MaxReceiveSize : unlimited
PoliciesIncluded : {{BDC31B4A-548E-4497-A44D-5C214E1E37FC},{2
6491CFC-9E50-4857-861B-0CB8DF22B5D7}}
PoliciesExcluded : {}
EmailAddressPolicyEnabled : True
PrimarySmtpAddress : Senate@e12dom.local
RecipientType : MailUniversalDistributionGroup
RecipientTypeDetails : MailUniversalDistributionGroup
RejectMessagesFrom : {}
RejectMessagesFromDLMembers : {}
RequireSenderAuthenticationEnabled : True
SimpleDisplayName :
UMDtmfMap : {}
WindowsEmailAddress : Senate@e12dom.local
IsValid : True
OriginatingServer : e12.e12dom.local
ExchangeVersion : 0.1 (8.0.535.0)
Name : Senate
DistinguishedName : CN=Senate,OU=Congress,DC=e12dom,DC=local
Identity : e12dom.local/Congress/Senate
Guid : b3b72fe4-4755-4aa6-90ad-63195661bdec
ObjectCategory : e12dom.local/Configuration/Schema/Group
ObjectClass : {top, group}
WhenChanged : 2/7/2007 8:23:06 AM
WhenCreated : 2/7/2007 8:23:06 AM

GroupType : Universal
SamAccountName : House
ExpansionServer :
ReportToManagerEnabled : False
ReportToOriginatorEnabled : True
SendOofMessageToOriginatorEnabled : False
ManagedBy :
AcceptMessagesOnlyFrom : {}
AcceptMessagesOnlyFromDLMembers : {}
AddressListMembership : {Default Global Address List, All Groups}
Alias : House
OrganizationalUnit : e12dom.local/Congress
CustomAttribute1 :
CustomAttribute10 :
CustomAttribute11 :
CustomAttribute12 :
CustomAttribute13 :
CustomAttribute14 :
CustomAttribute15 :
CustomAttribute2 :
CustomAttribute3 :
CustomAttribute4 :
CustomAttribute5 :
CustomAttribute6 :
CustomAttribute7 :
CustomAttribute8 :
CustomAttribute9 :
DisplayName : House
EmailAddresses : {SMTP:House@e12dom.local}
GrantSendOnBehalfTo : {}
HiddenFromAddressListsEnabled : False
LegacyExchangeDN : /o=First Organization/ou=Exchange Administ
rative Group (FYDIBOHF23SPDLT)/cn=Recipien
ts/cn=House1
MaxSendSize : unlimited
MaxReceiveSize : unlimited
PoliciesIncluded : {{BDC31B4A-548E-4497-A44D-5C214E1E37FC},{2
6491CFC-9E50-4857-861B-0CB8DF22B5D7}}
PoliciesExcluded : {}
EmailAddressPolicyEnabled : True
PrimarySmtpAddress : House@e12dom.local
RecipientType : MailUniversalDistributionGroup
RecipientTypeDetails : MailUniversalDistributionGroup
RejectMessagesFrom : {}
RejectMessagesFromDLMembers : {}
RequireSenderAuthenticationEnabled : True
SimpleDisplayName :
UMDtmfMap : {}
WindowsEmailAddress : House@e12dom.local
IsValid : True
OriginatingServer : e12.e12dom.local
ExchangeVersion : 0.1 (8.0.535.0)
Name : House
DistinguishedName : CN=House,OU=Congress,DC=e12dom,DC=local
Identity : e12dom.local/Congress/House
Guid : 2e0783cc-045b-4f69-af9d-05c0e867bccd
ObjectCategory : e12dom.local/Configuration/Schema/Group
ObjectClass : {top, group}
WhenChanged : 2/7/2007 8:23:14 AM
WhenCreated : 2/7/2007 8:23:14 AM

Updating email addresses ...
Done

That's it! In this series of posts, hopefully I've demonstrated how easy it is to do effective and exciting demos of Exchange functionality with PowerShell and the Scriptacular Demo Pack.

We'd love to get your feedback on demo ideas or demo experiences you've had with PowerShell and Exchange. Happy PowerShelling!

Comments

  • Anonymous
    January 01, 2003
    Preserving Nickname Cache in Exchange Migrations Apple challenges Microsoft Exchange Google to Replace