Information about Exchange Mgmt Shell Scripts
This page describes and lists various Exchange Mgmt Shell Scripts and how to use them.
permissions
To add mailbox permissions for yourself use run-as to launch Exchange Mgmt Shell using the someserviceacct service account and enter this:
Add-mailboxpermission -identity <user> -accessrights fullaccess -user <yourname>
Mailbox Storage and Statistics
note - Must Add Exchange Mgmt Shell SnapIn to PowerShell to Run Scripts on PowerShell
run this in PowerSherll: add-pssnapin Microsoft.Exchange.Management.PowerShell.Admin Microsoft.Exchange.Management.PowerShell.E2010 Microsoft.Exchange.Management.PowerShell.Support
How to list mailbox user
GET-Mailbox –identity twalters
How to get mailbox statisics of user
Get-MailboxStatistics -identity twalters
set-MailboxStatistics - identity twalters | select DisplayName, TotalItemSize, TotalDeletedItemsize, DatabaseName | format-table
Get Mailbox Stats of Mailbox Server
get-mailboxstatistics -server SomeMailServer | Sort-Object TotalItemSize –Descending | ft DisplayName,TotalItemSize,ItemCount
How to Increase a mailbox storage size from defaults. Use the set-mailbox cmdlet. This increases and sets the warning, prohibit send, and prohibit send and receive limits to 750mb, 800mb, and 900mb respectively and the defaults are ignored.
set-mailbox -identity username -IssueWarningQuota 786432000 -ProhibitSendQuota 838860800 -ProhibitSendReceiveQuota 943718400 -UseDatabaseQuotaDefaults $false or
Set-Mailbox
testmbx -UseDatabaseQuotaDefaults:$False -IssueWarningQuota 750MB
-ProhibitSendQuota 800MB -ProhibitSendReceiveQuota 900MB
Set Mailbox to Default Limits
set-mailbox -identity username -UseDatabaseQuotaDefaults $true
Mailbox Queue
Get-Queue -Filter {status -eq "retry"}
Mailbox Distribution Lists
How to list all distribution groups in OU
get-distributiongroup -OrganizationalUnit "mydomain/My DL GROUPs"
How to list members of a Distribution Group
Get-DistributionGroupMember –identity “distro
- some distrogroup" (replace " " w/any DG) add | ft name,
primarysmtpaddress | Export-CSV c:\members.csv to export to CSV
How to list a Users Distribution Group Membership
How to Remove a Distribution Group
Remove-DistributionGroup -Identity "DG Name"
How to Remove a User from a Distribution Group
Remove-DistributionGroupMember -Identity "DG Name" -Member user@Mydomain.com
How to add permission to Manage a Distribution Group
Set-DistributionList DLName -ManagedBy user1@domain.com,user2@domain.com
get-content Distros.txt | foreach-object { set-group -id $_ -managedBy user1@mydom.com, user2@mydom.com }
Add-ADPermission -Identity distro -User username -AccessRights WriteProperty -Properties "Member"
How to export mailbox for archiving (use z1.ps1 from NetAdmin Script Repo)
$username = Read-Host "Enter Username" $servername = Read-Host "Enter the Servername for User's H: drive" $pathname = "\\" + $servername + "\" + $username + "$\data\other" Export-Mailbox -Identity $username -PSTFolderPath $pathname -Confirm:$false
list primary smtp address
See Managed By for Distro
How to List Member of said group or dl.
[PS]
H:\>dsget group -members "CN=Some MailBox -Support,OU=Groups,OU=CITY,OU=Site1,DC=Company1,DC=com" | dsget
user -samid samid PShimizu dsget succeeded
This command allows other command to access the mailbox in all the child domains:
Set-ADServerSettings -ViewEntireForest:$true
Mailbox
migration commands that will migrate any mailbox in any domain that is
listed in the Alias column of a .CSV file but Suspend the move until you
are ready to start:
Set-ADServerSettings -ViewEntireForest:$true
import-csv C:\TempUserMoves1.csv | foreach {New-MoveRequest -Identity $_.Alias -BadItemLimit 10 -suspend } | find multiple
Mailbox
migration commands that will migrate any mailbox in any domain thats
listed in the Alias column of a .CSV file but Suspend the move at the
end of the migration. Only works on Exchange 2010 to 2010:
Set-ADServerSettings -ViewEntireForest:$true
import-csv
C:\Temp\UserMoves1.csv | foreach {New-MoveRequest -Identity $_.Alias
-BadItemLimit 10 -SuspendWhenReadyToComplete} | find multiple
Resume suspended move request:
import-csv C:\Temp\UserMoves1.csv | foreach {Resume-MoveRequest -Identity $_.Alias -Confirm:$False} | find multiple
To exclude mailbox database from provisioning , launch EMS and type:
Set-MailboxDatabase -Identity ussd-mbdb01 -IsExcludedFromProvisioning $true
To re-enable the mailbox database for provisioning, launch EMS and type:
Set-MailboxDatabase -Identity ussd-mbdb01 -IsExcludedFromProvisioning $false
A script that move all public folder content from one server to another server:
cd 'C:\Program Files\Microsoft\Exchange Server\v14\Scripts'
.\MoveAllReplicas.ps1 -Server ussd-prd-esmb01 -NewServer ussd-prd-esmb03
The location were the Exchange 2010 Scrip's are Stored:
cd 'C:\Program Files\Microsoft\Exchange Server\v14\Scripts'
These are the commands I used to set the attributes on the conference after they were migrated to Exchange 2010:
import-csv C:\temp\roomlist.csv | foreach {Set-Mailbox -Identity $_.Alias -Type Room}
import-csv
C:\temp\roomlist.csv | foreach {Set-CalendarProcessing -Identity
$_.Alias -AutomateProcessing AutoAccept -BookingWindowInDays 270}
A
command will export a mailbox to a PST file on a file share: (In order
for these commands to work the [Exchange Servers] group must have full
access to the folder you are righting to)
Set-ADServerSettings -ViewEntireForest:$true
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
This
command is used when create conference room to the Calendar reviewer
for everyone using the Alias column of a .CSV file. Most push Enter
twice for command to run:
import-csv C:\Temp\ConfRoom.csv | foreach { $room = $_.Alias + ':\calendar'
Set-MailboxFolderPermission -Identity $room -AccessRights Reviewer -User "Default" }
This command creates Room List DLs:
New-DistributionGroup “Room Name” –RoomList –Members “Conference You would like to added to the DL”
This command is used to check the health of the Content Index on the DBs. It must be ran from the mailbox server:
Get-MailboxDatabaseCopyStatus | fl name, contentindexstate
This command forces DAG fail over ofdatabase when it is Crawling:
Move-ActiveMailboxDatabase USSD-MBDB08 -SkipClientExperienceChecks
List Mailboxes by Size on a Database:
Get-MailboxDatabase ussd-mbdb02 | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, itemcount
Removes the Hidden from Address book using the Alias filed in a .CSV:
import-csv C:\Temp\GoLive.csv | foreach {Set-Mailbox -Identity $_.Alias -HiddenFromAddressListsEnabled $false} | find multiple
Set
the Accept Messages to all if a DL is set to be the only group to have
rights to send to a user based on the Alias filed in a .CSV:
import-csv C:\Temp\GoLive2.csv | foreach {Set-Mailbox -Identity $_.Alias -AcceptMessagesOnlyFromDLMembers $NULL} | find multiple
When
creating a new Public Database you will need to include it has a
replicate. This scrip will add a new Public Database as a replicate
based on the server name to all of the public folders. This command
needs to be ran from a server that already contains a Public Database:
cd 'C:\Program Files\Microsoft\Exchange Server\v14\Scripts'
.\AddReplicaToPFRecursive.ps1 -TopPublicFolder "\" -ServerToAdd servername
.\AddReplicaToPFRecursive.ps1 -TopPublicFolder "\NON_IPM_SUBTREE" -ServerToAdd servername
Give
the members of a DL Send on Behalf of right of the DL. You must have
manager permissions to the group for this command to work and the group
must be both a DL and a security group.
Set-DistributionGroup -Identity "DL-Finance_Revenue" -GrantSendOnBehalfTo "DL-Finance_Revenue"
This command shows you the size of a Database and how much free space is available in it.
Get-MailboxDatabase "MailBoxServerName" -Status | Select-Object Server,Name,AvailableNewMailboxSpace,databasesize
Exchange Mgmt Shell Links