Here are some handy commands for Exchange 2010.
- How to remove users from Exchange without removing them from AD
First get Disabled users :
| Get-MailboxDatabase | Clean-MailboxDatabase |
| $mailboxes = Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, mailboxguid, database |
Remove Disabled users :
| $mailboxes | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false } |
You will recive the following error when there are no disconnected mailboxen in the disconnected mailbox folder, you can then ignore the message
| Cannot bind argument to parameter 'Database' because it is null. + CategoryInfo : InvalidData: (:) [Remove-Mailbox], ParameterBindingValidationE + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Remove-Mailbox |
Change Languages for the user(s)
When yo want to change a Language for a user enter the following :
| Set-Mailbox -Identity "Full Username - John Smith" -Languages "uk-UK / jp-JP / nl-NL etc." |
If you want all the users changed :
| $servers = Get-mailboxserver | where {$_.admindisplayversion -like "Version 14*"} foreach($server in $servers) {Get-Mailbox -server $server -resultsize unlimited | SET-mailbox -languages "uk-UK / jp-JP / nl-NL etc"} |
Go in the users mailbox using the web interface and set in OPTIONS --> ALL OPTIONS --> SETTINGS --> Country Settings the language.
do not forget to select the change all default maps !
Get Statistics of all active (not disconnected) mailboxes
Run the following command to get the Total item size & Item count:
| Get-MailboxStatistics -server servername| ?{$_.totalItemSize.Value.ToMB() -gt 500} | Sort-Object TotalItemSize -Descending | Select DisplayName,@{name="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount | Export-CSV c:\stats.csv -force -noTypeInformation -encoding ASCII |
* Set the Servername & file location + filename of the cvs !
Add access privileges
New-ManagementRoleAssignment -Name:"MailStore Impersonation" -Role:ApplicationImpersonation -User:Dit e-mailadres wordt beveiligd tegen spambots. JavaScript dient ingeschakeld te zijn om het te bekijken.
Important notice:
Check access privileges
Get-ManagementRoleAssignment -Role:ApplicationImpersonation -RoleAssigneeType:User | Format-List * Get-ManagementRoleAssignment -Identity:"MailStore Impersonation" | Format-List *
Remove access privileges
The following command is only to be used, if you want to remove access privileges from
Remove-ManagementRoleAssignment "MailStore Impersonation"
Creating and Assigning an Individual Throttling Policy
To avoid interfering with the overall stability of the Exchange 2010 system by using a too liberal policy definition of the default throttling policy, it is advisable to create a separate policy for the serviceaccount. Only three lines are necessary to create a throttling policy for the serviceaccount which is customized for MailStore:
New-ThrottlingPolicy MailStore Get-ThrottlingPolicy MailStore | Set-ThrottlingPolicy -EWSFindCountLimit 2500 -EWSPercentTimeInAD 70 -EWSPercentTimeInCAS 120 -EWSPercentTimeInMailboxRPC 80 Set-Mailbox "servcieaccount" -ThrottlingPolicy MailStore
In line 1, a new throttling policy is created, line 2 defines the desired values for the policy, and in line 3, the individual throttling policy is assigned to the serviceaccount.
Important: Please note that a mailbox must be set up for the serviceaccount in order to be able to assign a policy to it.
Removing and Deleting an Individual Throttling Policy
To delete an individual throttling policy from a mailbox or user account, execute the following command in the Exchange Management Shell:
Set-Mailbox "Serviceaccount" -ThrottlingPolicy $null
This ends the assignment of a throttling policy. To delete the throttling policy from the Exchange system, execute the following command in the Exchange Management Shell:
Remove-ThrottlingPolicy MailStore
Confirm this by entering "Y". The policy is now completely deleted from the system.
Handy commands
|
Usefull Exchange 2010 Powershell Commando’s {Get mailbox copy status information} Get-MailboxDatabaseCopyStatus -Identity “Mailbox Database Name” | select DatabaseName,Status,ActiveDatabaseCopy,ContentIndexState “{Import PST Files}” “{Get Information about a mailbox}” “{Purge Disconnected Mailbox}” or $users = Get-MailboxStatistics -database “Mailbox Database Name” | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid,Database $users | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false } “{Run cleanup agent}” “{Show all Mailboxes which are bigger than 400 mb and sorted}” “{Show mailbox Size From a user in MB}” “{Whitelist a sender}” “{Show mailbox databases storage quota}” “{Set ‘send-as’ Rights}” “{Set ‘Full Access’ Rights}” “{Get Mailbox users which never logged-on}” “{Mailbox users who logged on after 3-31-2010}” “{Show mailbox forwarding roles}” “{Add Database copy to a Mailbox server }” “{Update Database Copy (Reseeding), Delete files if exist}” “{Reseed the Search Catalog}” “{Certificate Generate CSR}” New-ExchangeCertificate -FriendlyName ‘Test’ -GenerateRequest -PrivateKeyExportable $true -KeySize ’2048′ -SubjectName ‘C=NL,S=”Noord-Brabant”,L=”Eindhoven”,O=”more2know”,OU=”ICT”,CN=webmail.more2know.nl’ -DomainName ‘autodiscover.more2know.nl’ “{Import Certificate}” In the popup enter a username. It will not used. Enter the password that protect your pfx certificate “{Show free Space Database}” Get-MailboxDatabase -Status | Select-Object Server,Name,AvailableNewMailboxSpace “{Create a new Recovery Database}” “{Recover A Mailbox from the Recovery Database}” “{Recover A Mailbox from the Recovery Database to folder}” “{Recover A Mailbox Content from the Recovery Database to folder}” “{Restore all from Recoverydatabase}” “{Remove Recoverydatabase}” “{Suspent all databases on a server for activation only}” “{Resume all databases after a suspend only activation only}” “{Move all database to another server}” “{Show all activation preferences}” “{Mount database on the server with preference 1 (with colors)}” “{Verify if the database is mounted on the server with preference 1 (with colors)}” |