Getting Mailbox sizes


Remember the days when you could open ESM click on the mail store and see all the mailbox sizes? then you could sort them with a click and  know which users to go have a discussion with about mail usage? Where did that go in Exchange 2010\2007?

You can use powershell to gather all that info and export it to a CSV

Get-MailboxStatistics | sort-object totalitemsize -Descending  | select-object displayname, itemcount, totalitemsize | Export-Csv -path c:\mboxStats.csv

Or if you want the GUI back

Glen Scales Developed a very cool powershell script that gives you a GUI for mailbox sizes

Exchange 2010 http://gsexdev.blogspot.com/2010/03/mailbox-size-gui-exchange-2010-remote.html

Exchange 2007 http://gsexdev.blogspot.com/2008/05/version-5-of-mailbox-size-gui-script.html

My only gripe is that he thought of it first Smile

Great script man!

Troubleshooting through comparison


Ever run into an issue where one user or server works but another doesn’t and you wonder “what’s different”? Powershell to the rescue!! using compare-object and get content against the output of a get- command.

I am working on a script that all you have to do is answer the questions, and another to pull all the pertinent data for an environment and provide a comparison.

But for now here are some examples to get you started:

Compare user settings

  • get-casmailbox UserA| fl > c:\a.txt
  • get-casmailbox userB| fl > c:\b.txt
  • or
  • get-mailbox UserA| fl > c:\a.txt
  • get-mailbox userB| fl > c:\b.txt

Compare CAS server settings

  • get-ClientAccessServer ServerA | fl > c:\a.txt
  • get-ClientAccessServer ServerB | fl > c:\b.txt

Compare Exchange Servers

get-EXchangeServer ServerA | fl > c:\a.txt
get-EXchangeServer ServerB | fl > c:\b.txt

Run

Compare-Object $(Get-Content c:\a.txt) $(Get-Content c:\b.txt) -includeequal

 

Here is the draft of the script, you will notice that there are several slots open for additional comparison please let me know if you would like me to add something to it or if you have any issues.

EDIT – I have added Service state and fixed 2 bugs I found in the script.

****************Start Of Script***************************************************

CLS
write-host
write-host
write-host Script provided by http://ExchangeMaster.wordpress.com -ForegroundColor green
write-host Exchange Server 2010\2007 – comparison script
write-host Please, select which comparison you are going to run..
write-host
write-host ’1) Compare Exchange servers’
write-host ’2) Compare 2010 CAS servers’
write-host ’3) Compare Mailbox servers’
write-host ’4) Compare Transport servers’
write-host ’5) Compare 2007 CAS servers’
write-host ’6) Compare Mail Enabled users’
write-host ’7) Compare Service State’
write-host ’8) ’
write-host ’9) ’
write-host ’10)’
write-host
write-host “Select an option.. [1-10]? “
$opt = read-host

switch ($opt)
    {
        1 { $serverA = read-host "Enter the name of the fisrt server"
    $ServerB = read-host "Enter the name of the second server"
    get-exchangeserver $ServerA | fl >  $env:temp\$ServerA.txt        
    get-exchangeserver $ServerB | fl >  $env:temp\$serverb.txt
    Get-Service -ComputerName $ServerA |Ft  name, status -a >>  $env:temp\$ServerA.txt
    Get-Service -ComputerName $ServerB |Ft  name, status -a >>  $env:temp\$serverb.txt
    Compare-Object $(Get-Content  $env:temp\$ServerA.txt) $(Get-Content  $env:temp\$serverb.txt) -includeequal > $env:temp\Compare_2010_EXchange.txt
    Invoke-Item $env:temp\Compare_2010_Exchange.txt}

        2 { $serverA = read-host "Enter the name of the fisrt server"
    $ServerB = read-host "Enter the name of the second server"
    Get-ClientAccessServer $ServerA | fl >  $env:temp\$ServerA.txt
    Get-OwaVirtualDirectory -Identity $servera\* | fl name, server, *url*, *auth*, *enabled, *version >> $env:temp\$ServerA.txt
    Get-ecpVirtualDirectory -Identity $servera\* | fl name, server, *url*, *auth*, *enabled, *version >> $env:temp\$ServerA.txt   
    Get-webservicesVirtualDirectory -Identity $servera\* | fl server, name, internalurl, externalurl >> $env:temp\$ServerA.txt
    Get-oabVirtualDirectory -Identity $servera\* | fl server, name, internalurl, externalurl >> $env:temp\$servera.txt
    Get-ClientAccessServer $Serverb | fl >  $env:temp\$ServerB.txt
    Get-OwaVirtualDirectory -Identity $serverb\* | fl name, server, *url*, *auth*, *enabled, *version >> $env:temp\$serverb.txt
    Get-ecpVirtualDirectory -Identity $serverb\* | fl name, server, *url*, *auth*, *enabled, *version >> $env:temp\$serverb.txt
    Get-webservicesVirtualDirectory -Identity $serverb\* | fl server, name, internalurl, externalurl >> $env:temp\$serverb.txt
    Compare-Object $(Get-Content  $env:temp\$ServerA.txt) $(Get-Content  $env:temp\$serverb.txt) -includeequal > $env:temp\Compare_2010_Cas.txt
    Invoke-Item $env:temp\Compare_2010_Cas.txt}

        3 { $serverA = read-host "Enter the name of the fisrt server"
    $ServerB = read-host "Enter the name of the second server"
    get-mailboxServer $ServerA | fl >  $env:temp\$servera.txt
    get-mailboxServer $ServerB | fl >  $env:temp\$ServerB.txt
    Compare-Object $(Get-Content  $env:temp\$ServerA.txt) $(Get-Content  $env:temp\$serverb.txt) -includeequal > $env:temp\Compare_2010_MAilbox.txt
    Invoke-Item $env:temp\Compare_2010_mailbox.txt}

        4 {$serverA = read-host "Enter the name of the fisrt server"
    $ServerB = read-host "Enter the name of the second server"
    get-TRansportServer $ServerA | fl >  $env:temp\$servera.txt
    get-transportServer $ServerB | fl >  $env:temp\$ServerB.txt
    Compare-Object $(Get-Content  $env:temp\$ServerA.txt) $(Get-Content  $env:temp\$serverb.txt) -includeequal > $env:temp\Compare_2010_Transport.txt
    Invoke-Item $env:temp\Compare_2010_Transport.txt}

        5 { $serverA = read-host "Enter the name of the fisrt server"
    $ServerB = read-host "Enter the name of the second server"
    Get-ClientAccessServer $ServerA | fl >  $env:temp\$ServerA.txt
    Get-OwaVirtualDirectory -Identity $servera\owa* | fl name, server, *url*, *auth*, *enabled, *version >> $env:temp\$ServerA.txt
    Get-webservicesVirtualDirectory -Identity $servera\* | fl server, name, internalurl, externalurl >> $env:temp\$ServerA.txt
    Get-oabVirtualDirectory -Identity $servera\* | fl server, name, internalurl, externalurl >> $env:temp\$servera.txt
    Get-ClientAccessServer $Serverb | fl >  $env:temp\$ServerB.txt
    Get-OwaVirtualDirectory -Identity $serverb\owa* | fl name, server, *url*, *auth*, *enabled, *version >> $env:temp\$serverb.txt
    Get-webservicesVirtualDirectory -Identity $serverb\* | fl server, name, internalurl, externalurl >> $env:temp\$serverb.txt
    Get-oabVirtualDirectory -Identity $serverb\* | fl server, name, internalurl, externalurl >> $env:temp\$serverb.txt   
    Compare-Object $(Get-Content  $env:temp\$ServerA.txt) $(Get-Content  $env:temp\$serverb.txt) -includeequal > $env:temp\Compare_2007_Cas.txt
    Invoke-Item $env:temp\Compare_2007_Cas.txt}

        6 { $userA = read-host "Enter the name of the First user"
    $userB = read-host "Enter the name of the second user"
    get-mailbox $userA | fl >  $env:temp\$usera.txt
    get-casmailbox $userA | fl >>  $env:temp\$usera.txt
    get-Mailboxpermission $userA | fl >>  $env:temp\$usera.txt
    get-mailbox $userB | fl >  $env:temp\$UserB.txt
    get-casmailbox $userB | fl >>  $env:temp\$UserB.txt
    get-Mailboxpermission $userB | fl >>  $env:temp\$USerB.txt
    Compare-Object $(Get-Content  $env:temp\$userA.txt) $(Get-Content  $env:temp\$userb.txt) -includeequal > $env:temp\Compare_user.txt
    Invoke-Item $env:temp\Compare_user.txt}

        7 { $serverA = read-host "Enter the name of the fisrt server"
    $ServerB = read-host "Enter the name of the second server"
    Get-Service -ComputerName $ServerA |Ft  name, status -a >  $env:temp\$ServerA.txt
    Get-Service -ComputerName $ServerB |Ft  name, status -a >  $env:temp\$serverb.txt
    Compare-Object $(Get-Content  $env:temp\$ServerA.txt) $(Get-Content  $env:temp\$serverb.txt) -includeequal > $env:temp\Compare_SErvices.txt
    Invoke-Item $env:temp\Compare_SErvices.txt}
    8 { }
        9 { }
        10 { }
        default {write-host “You haven’t selected any of the available options. “}
    }

*****************End of Script***********************************************************

Recipients Creation Script For Exchange 2010 or 2007


I have been building labs constantly and found that I needed a way to quickly populate my exchange environments with users. here is the powershell scripts I use

1. Save the following as Provisionusers.ps1

$Password=Read-Host “Enter Password” -AsSecureString
Import-CSV CreateRecipients.csv | foreach {new-mailbox -alias $_.name -name $_.Name -userPrincipalName $_.userPrincipalName -database $_.Database -org $_.OrganizationalUnit -lastname $_.Lastname -firstname $_.Firstname -Password $Password}

2. Save this as CreateRecipients.csv

Database,UserPrincipalName,OrganizationalUnit,Name,LastName,FirstName
Mailbox Database 1936175296,user@domain.com,Domain.local/Lab Users/OU1,User1,Last1,First1
2k3server\First Storage Group\Mailbox Store (2k3server),user@domain.com,Domain.local/Lab Users/OU2,User2,Last2,First2
2k7Server\First Storage Group\Mailbox Database,user@domain.com,Domain.local/Lab Users/OU3,User3,Last3,First3

3. Edit the csv file with the users you want to load

4. Open Exchange Powershell and CD to the directory where the files are saved, and then type ./Provisionusers.ps1, it will prompt you for a password, this is the default password that will be used.

Note: You may have to change the Powershell Security policy
Set-ExecutionPolicy Unrestricted or Set-ExecutionPolicy RemoteSigned

Mail Box Creation parameters http://technet.microsoft.com/en-us/library/aa997663.aspx
Thanks for the info Bharat to get me going