Pages

Thursday 28 January 2010

Exchange Powershell Commands

Please check out www.kaztechsolutions.co.uk 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 "london.HQNNET.com/London/Groups/Contacts" }


This is the book1.csv file that was imported - look at the format
DisplayName FirstName LastName Emailaddress Alias OrganizationalUnit
Ted Smith (Internet) Ted Smith ted.smith@easons.com tedsmith domain.com/London/Groups/Contacts


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 contoso.com domain, run the following command:
$AdminSessionADSettings.DefaultScope = "contoso.com/Marketing Users"


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


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


Test Outlook Web Services for a certain user and output them in to a DOS box
Test-OutlookWebServices -I gerrish@domain.co.uk | 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 'domain.contoso.com/Users/Paula' -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 "ExchSrv01.domain.com"

Public Folder cmdlets: http://technet.microsoft.com/en-us/library/bb232202(EXCHG.80).aspx



No comments:

Post a Comment