Powered by Ed Buford and Coffee

Category: Powershell

Mailbox Migration quick view

Frequently I start mailbox migrations on a Friday night and then babysit the moves all weekend long (or longer). Clients like to know some basic info about the move just to check to make certain things are going as expected.

Now when you’re moving hundreds of users at a time the last thing you want to do is try to count all the users that are completed so you can give an update to your clients. So I created a simple powershell script to tell me how many users are Queued, completed, failed or moving.  Hope this is helpful:

# Simple script to Display Mailbox migration stats
# 1.0 Ed Buford AKA ExchangeNerd (or just Nerd for short)

$queued=Get-MoveRequest | Where {$_.status -eq "Queued"}
$comp=Get-MoveRequest | Where {$_.status -eq "Completed"}
$Failed=Get-MoveRequest | Where {$_.status -eq "Failed"}
$move=Get-MoveRequest | Where {$_.status -eq "Inprogress"}

write-host There are $queued.count mailboxes Queued -foregroundcolor Green
Write-host There are $move.count Mailboxes moving -foregroundcolor Green
Write-host there are $comp.count Mailboxes Completed -foregroundcolor Green
Write-host there are $failed.count Mailboxes Failed -foregroundcolor Green

Multi Mailbox search in Office 365

I’ve was asked to do a Multi-Mailbox search in Office 365 to gather some email when their Journal somehow stopped Journaling.

Now In Exchange I could do this without much thought but doing anything in Office 365 takes me a lot longer as there just don’t seem to be great blogs written on the mundane things I want to do as of yet so I thought I’d add my own.

The Task:
Gather together all the email (undeleted) over the past month and export it to a PST.

  • The user creating this request must have an SMTP address the same as the mailboxes you’re searching (this means the user must be a mailbox user).
  • The user creating this request must be a member of the Discovery Management role group.
  • You need to use the User Principal Name in the of the Discovery Mailbox in order to send the mailbox to create the Powershell Request.

The Solution:

Find your Discovery Mailbox

Get-Mailbox -Resultsize unlimited -Filter {RecipientTypeDetails -eq “DiscoveryMailbox”

Find the User Principal Name for the Mailbox:

Get-Mailbox -Resultsize unlimited -Filter {RecipientTypeDetails -eq “DiscoveryMailbox”} |FL UserPrincipalName

Get Discovery management Group Members:
Get-RoleGroupMember -Identity “Discovery Management”

Add User to Discovery Management
Add-RoleGroupMember -Identity “Discovery Management” -Member USERNAME

Create the search:
New-MailboxSearch “SearchName” -StartDate “1/1/2014” -EndDate “1/22/2014″ -TargetMailbox ” Discovery Mailbox UPN” -MessageTypes Email -IncludeUnsearchableItems -LogLevel Full

Start the Search:
Start-MailboxSearch “SearchName”

Get-MailboxSearch |FL


Quick Weather

A script a co-worker wrote to grab weather

$url = ""
$data = Invoke-RestMethod $url
$temp = $data.current_observation.temp_f -as [decimal]
$wind = $data.current_observation.wind_mph -as [decimal]
$weather = $

$temp_desc = $null
$wind_desc = $null

    { $_ -le 15 } { $temp_desc = "stupidly cold outside" }
    { $_ -le 40 -and $_ -gt 15 } {$temp_desc = "cold outside"}
    { $_ -le 60 -and $_ -gt 40 } {$temp_desc = "a little chilly outside"}
    { $_ -le 80 -and $_ -gt 60 } {$temp_desc = "warm and comfortable outside"}
    { $_ -le 90 -and $_ -gt 80 } {$temp_desc = "quite warm outside"}
    { $_ -le 100 -and $_ -gt 90 } {$temp_desc = "hot outside"}
    { $_ -gt 100 } {$temp_desc = "stupidly hot outside"}

    { $_ -le 0 } {$wind_desc = "quiet, a little too quiet...."}
    { $_ -le 5 -and $_ -gt 0 } {$wind_desc = "a gental breeze."}
    { $_ -le 10 -and $_ -gt 5 } {$wind_desc = "a brisk draft."}
    { $_ -le 15 -and $_ -gt 10 } {$wind_desc = "quite a bit windy."}
    { $_ -le 20 -and $_ -gt 15 } {$wind_desc = "blowing more than you would like."}
    { $_ -le 25 -and $_ -gt 20 } {$wind_desc = "frustratingly powerful."}
    { $_ -ge 26 } {$wind_desc = "an unstopable hurricane!"}

"The weather is currently $temp_desc with winds that are $wind_desc You might also notice it's $weather."

Save the script and then execute it like this:


Another one-line example:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri  -Credential $LiveCred -Authentication Basic –AllowRedirection