Pages

Search This Blog

Friday, August 2, 2013

Useful PowerShell cmdlets for Exchange Server admins

Using Exchange Management Shell (EMS) can always provide admins with more flexibility and ability to do some tasks that are not attainable though the use of Exchange Management Console (EMS)  . In this post I will share some of useful PowerShell cmdlets which can do some required-by-admins tasks in a fast, easy and efficient way .

All required to be entered data are bold, italic and highlighted !

  • Calculate the actual total consumption in megabytes by a collection of mailboxes located at a specific Organizational Unit (OU) :

Get-Mailbox –OrganizationalUnit ‘DomainName/OUName -ResultSize Unlimited | ForEach-Object {$_.TotalItemSize.Value.ToMB()} | Measure -Sum | Select-object Sum

  • Calculate the maximum total consumption in megabytes for a collection of mailboxes located at a specific Organizational Unit (OU) – based on the the quota’s prohibit send and receive :

Get-Mailbox –OrganizationalUnit ‘DomainName/OUName -ResultSize Unlimited | ForEach-Object {$_.ProhibitSendReceiveQuota.Value.ToMB()} | Measure -Sum | Select-object Sum

  • List members of a distribution group and get the output as member’s name and email address :

Get-DistributionGroupMember –Identity ‘Group Name | Select-Object Name,PrimarySmtpAddress

  • List non-members of a distribution group based on Organizational Unit and get the output as non-member’s name and email address :

$N=@() ;$M=(Get-Group ‘Group Name’).members;Get-Recipient –OrganizationalUnit DomainName/OUName | foreach { if ( $m –notcontains $_.distinguishedname) { $n += $_}};$N | Select-object DisplayName,PrimarySmtpAddress

  • Retrieve a specific user’s aliases separating the PrimarySmtpAddress from non-PrimarySmtpAddresses :

Get-Mailbox –OrganizationalUnit ‘DomainName/OUName’ –Identity ‘User Name’ | Select-object DisplayName,PrimarySmtpAddress,@{Name="EmailAddresses";Expression={$_.EmailAddresses | Where-Object {$_.PrefixString -ceq "smtp"} | ForEach-Object {$_.SmtpAddress}}}

  • List all non-primary SMTP addresses for a user’s mailbox :

$Aliases=(Get-Mailbox –Identity ‘User Name).EmailAddresses; $Aliases | Where-Object {$_.PrefixString -ceq 'smtp' } | Select-Object SMTPAddress

  • Add additional email address to a user mailbox :

Set-Mailbox –Identity ‘User Name -EmailAddresses @{Add=username@domainname.com}

Hope that it was useful Open-mouthed smile .

No comments:

Post a Comment