Exchange Demos with PowerShell - DotNet Objects
Continuing from the previous post, during the second part of the demo I introduced the details on how to interact with other .net objects, along with some of the PowerShell glue that makes manipulating Exchange objects so powerful:
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$dl = Get-DistributionGroup Homelandc*
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$dlName DisplayName GroupType PrimarySmtpAddress
---- ----------- --------- ------------------
HomeLandComission HomeLandComission Universal HomeLandComissio...[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$dl | fl
GroupType : Universal
SamAccountName : HomeLandComission
ExpansionServer :
ReportToManagerEnabled : False
ReportToOriginatorEnabled : True
SendOofMessageToOriginatorEnabled : False
ManagedBy :
AcceptMessagesOnlyFrom : {}
AcceptMessagesOnlyFromDLMembers : {}
AddressListMembership : {Default Global Address List, All Groups}
Alias : HomeLandComission
OrganizationalUnit : e12dom.local/Congress
CustomAttribute1 :
CustomAttribute10 :
CustomAttribute11 :
CustomAttribute12 :
CustomAttribute13 :
CustomAttribute14 :
CustomAttribute15 :
CustomAttribute2 :
CustomAttribute3 :
CustomAttribute4 :
CustomAttribute5 :
CustomAttribute6 :
CustomAttribute7 :
CustomAttribute8 :
CustomAttribute9 :
DisplayName : HomeLandComission
EmailAddresses : {SMTP:HomeLandComission@uscongress.gov}
GrantSendOnBehalfTo : {}
HiddenFromAddressListsEnabled : False
LegacyExchangeDN : /o=First Organization/ou=Exchange Administ
rative Group (FYDIBOHF23SPDLT)/cn=Recipien
ts/cn=HomeLandComission
MaxSendSize : unlimited
MaxReceiveSize : unlimited
PoliciesIncluded : {{B491E897-701A-4577-AC00-A3244FAC7BA2},{2
6491CFC-9E50-4857-861B-0CB8DF22B5D7}}
PoliciesExcluded : {}
EmailAddressPolicyEnabled : True
PrimarySmtpAddress : HomeLandComission@uscongress.gov
RecipientType : MailUniversalDistributionGroup
RecipientTypeDetails : MailUniversalDistributionGroup
RejectMessagesFrom : {}
RejectMessagesFromDLMembers : {}
RequireSenderAuthenticationEnabled : True
SimpleDisplayName :
UMDtmfMap : {}
WindowsEmailAddress : HomeLandComission@uscongress.gov
IsValid : True
OriginatingServer : e12.e12dom.local
ExchangeVersion : 0.1 (8.0.535.0)
Name : HomeLandComission
DistinguishedName : CN=HomeLandComission,OU=Congress,DC=e12dom
,DC=local
Identity : e12dom.local/Congress/HomeLandComission
Guid : 501492ee-246c-410d-a965-a22f9b1db504
ObjectCategory : e12dom.local/Configuration/Schema/Group
ObjectClass : {top, group}
WhenChanged : 2/7/2007 8:01:08 AM
WhenCreated : 2/7/2007 8:00:41 AM[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$dladdr = $dl.PrimarySmtpAddress.ToString()
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$dladdr
HomeLandComission@uscongress.gov
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$dls = Get-DistributionGroup
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$dlsName DisplayName GroupType PrimarySmtpAddress
---- ----------- --------- ------------------
Senate Senate Universal Senate@uscongres...
House House Universal House@uscongress...
HomeLandComission HomeLandComission Universal HomeLandComissio...[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$dls[0]
Name DisplayName GroupType PrimarySmtpAddress
---- ----------- --------- ------------------
Senate Senate Universal Senate@uscongres...[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$smtpclient = new-object System.Net.Mail.SmtpClient $server, 587
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$smtpclientHost : E12
Port : 587
UseDefaultCredentials : False
Credentials :
Timeout : 100000
ServicePoint : System.Net.ServicePoint
DeliveryMethod : Network
PickupDirectoryLocation :
EnableSsl : False
ClientCertificates : {}[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$cred = get-credential e12dom\exadmin
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$credUserName Password
-------- --------
e12dom\exadmin System.Security.SecureString[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$smtpclient.Credentials = $cred.GetNetworkCredential()
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>$smtpclient.Send("exadmin@uscongress.gov", $dladdr, "Welcome", "New list created.")
[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-queue -server $serverIdentity DeliveryType Status MessageCount NextHopDomain
-------- ------------ ------ ------------ -------------
e12\Submission Undefined Sus... 7 Submission[PS] C:\Program Files\Microsoft\Exchange Server\Scripts\TR4>get-message -queue $server\submission
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>while($true) { cls; get-message -queue $server\submission | ft; sleep 1; }
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 WelcomeIdentity 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 WelcomeIdentity 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-alias cls
CommandType Name Definition
----------- ---- ----------
Alias cls Clear-Host
In the next post, I'll cover the third part of the demo... using help and "finding things" in PowerShell. as well as introducing the concept of Exchange identity and filters (both traditional PowerShell client-side and Exchange's own server-side filters).
Comments
- Anonymous
January 01, 2003
How to: Install Exchange 2007 Management Tools for Windows Vista Look out BlackBerry, Palm is back Moving