ExchangeNerd

Powered by Ed Buford and Coffee

Archives: January 2014

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.
Discovery:

  • 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 = "http://w1.weather.gov/xml/current_obs/KSBN.xml"
$data = Invoke-RestMethod $url
$temp = $data.current_observation.temp_f -as [decimal]
$wind = $data.current_observation.wind_mph -as [decimal]
$weather = $data.current_observation.weather

$temp_desc = $null
$wind_desc = $null

switch($temp)
{
    { $_ -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"}
}

switch($wind)
{
    { $_ -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:

./Get-QuickWeather.ps1

Another one-line example:

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

 

[Top]