Thursday, 28 January 2010

Exchange Powershell Commands

Please check out for more of my technical posts, alternately please call us on 01932 268289. 

To gives full access permission to all the mailboxes 
Get-Mailbox | Add-MailboxPermission -AccessRights Fullaccess -User

To remove mailbox permissions
get-mailbox -server "servername" | remove-mailboxpermission -user Domain\Username_here -AccessRights "FullAccess"

Bulk imports Mail contacts in to Exchange2007 via a CSV file
Import-Csv c:\csv\book1.csv | ForEach { New-MailContact -Name $_.displayName -Firstname $_.FirstName -LastName $_.LastName -ExternalEmailAddress $_.Emailaddress -Alias $_.Alias -OrganizationalUnit "" }

This is the book1.csv file that was imported - look at the format
DisplayName FirstName LastName Emailaddress Alias OrganizationalUnit
Ted Smith (Internet) Ted Smith tedsmith

Get list of all mailboxes with all details and export to CSV file
Get-Mailbox | export-csv c:\csv\export.csv | Format-List

Get list of all Distribution Lists and export to CSV file
Get-DistributionGroup | export-csv c:\csv\DL.csv | FT Name, AddressListMembership

add full mailbox rights to a mailbox
Get-Mailbox -Identity server | Add-MailboxPermission -AccessRights fullaccess -User

to get a list of all users in a distribution list
Get-DistributionGroupMember -Identity "UK-Marketing Bulletin" | export-csv c:\DL.csv

to change the default search scope

To set the recipient scope to the Marketing Users OU in the domain, run the following command:
$AdminSessionADSettings.DefaultScope = " Users"

To set the recipient scope to the domain and use as the recipient domain controller, run the following commands:
$AdminSessionADSettings.DefaultScope = ""
$AdminSessionADSettings.PreferredDomainControllers = ""

To set the recipient scope to the entire forest and use as the global catalog server, run the following command:
$AdminSessionADSettings.ViewEntireForest = $True
$AdminSessionADSettings.PreferredGlobalCatalog = ""

Test Outlook Web Services for a certain user and output them in to a DOS box
Test-OutlookWebServices -I | fl

To check wheather a group has sender auth enabled
Get-DistributionGroup “Group? | Select-Object Name, RequireSenderAuthenticationEnabled

to disabled sender auth
Set-DistributionGroup “Group? -RequireSenderAuthenticationEnabled $False

Get Transport Servers full details exported to a CSV file
Get-TransportServer | export-csv c:\will.csv | Format-List

Add a user as a public folder admin
Add-ExchangeAdministrator -Identity '' -Role:'PublicFolderAdmin'

Get-Mailbox | Get-MailboxStatistics | select DisplayName,TotalItemSize| sort TotalItemSize | export-csv c:\filename.csv

Get a list of all SMTP address of all users.
Get-Mailbox | select -expand EmailAddresses | %{$_.SmtpAddress}

Get a list of currently logged on users
Get-LogonStatistics -Server SRV | export-csv c:\export.csv | Format-List

Get details of managed by in email distribution list
Get-DistributionGroup | fl displayname, managedby

Get full details of any mailbox with certain words in it.
get-mailbox *word* | fl

Give a user full rights over public folders

Add-PublicFolderAdministrativePermission -User username -Identity \PublicFolder -AccessRights AllExtendedRights

Get Cluster Information
Running a cluster res from CMD will show which Exchange Server is the current node in the cluster. 

running a cluster group "Cluster Group" /moveto:ExchSrv01 will move the cluster back to ExchSrv01. 

How to find out what server is accepting RPC Connection
get-mailboxdatabase | ft name,RpcClientAccessServer

Change which server a Mailbox with user for RPC connections.
Set-mailboxdatabase -Identity lonmbx1 -RpcClientAccessServer ""

Public Folder cmdlets:

No comments:

Post a Comment