Friday, December 20, 2013

ericwoodford.com reborn

It's been a few weeks, and I miss my old blog site. Here are a few things, I've been working on..

Quickly create an array of strings.
I use this when I've been given a list of something (smtp addresses, contact names, etc.) and need to search my servers for them. I cut and paste the code below into a Posh window, then paste in the data.

$s=@();do {$r=Read-Host "+";if($r -ne ""){$s+=$r.trim()}} while ($r -ne "")

Copy and paste from the source (html page, script run, email). When done, hit Enter for a blank line and now I can run my script against this list.


$s | %{get-mailbox $_} 

Dumping email from Exchange 2010 queues. 
Had an issue where mail was incorrectly routed to a send-connector that couldn't actually route email. I found that I could export the messages to an .eml file, but I couldn't the "AssembleMessage" filter they referenced. Of course, try from the Exchange Management Shell and it worked fine.

#Grab all queues that belong to the send connector
$queues = get-TransportServer | get-queue | ?{$_.nextHopDomain -eq "SendConnectorName"}
#Must suspend the queues
$queues | suspend-queue
#Must suspend the emails in each queue
$queues | get-message | suspend-message
$msgs = $queues | get-message 
#AssembleMessage filter is available when you run from the EMS.
$msgs | ForEach-Object {$i++; Export-Message $_.Identity | AssembleMessage -Path ("c:\Export_messages\"+ $_.internetMessageId.replace("<","").replace(">","") +".eml")}

This grabs all of your email and drops it in the local folder. This next part I haven't been allowed to test, because I could create duplicate email messages.
  1. Find your Replay directory path on your servers.
    Get-TransportServer | select ReplayDirectoryPath
    
    ReplayDirectoryPath
    -------------------
    C:\Program Files\Exchange\TransportRoles\Replay

  2. Browse to that folder. I don't have one, so I was going to create one.
  3. Copy the emails into that folder and the transport service should pick them up.

Find all mailboxes tagged with a target address going to a specific domain.
Right now we have 3 concurrent migrations to our email system. This means that there are approximately 2,000 mailboxes that are tagged with various target addresses.

get-aduser -ldapfilter '(targetAddress=*gmail.com)'

or using the Quest ARS Powershell cmdlets.

get-qaduser -includedproperties targetaddress -ldapfilter '(targetAddress=*gmail.com)'

I like the Quest tools, because I know how to easily feed it back into and blank it out.

Get-QADUser -includedproperties targetaddress -ldapfilter '(targetAddress=*gmail.com)' | Set-QADUser -ObjectAttributes @{'targetAddress'=$null}

2 comments:

  1. Hi Eric,
    Sorry that contact you so add as this way. Currently I am working for setting default GAL for outlook 2010 and found your script from http://social.technet.microsoft.com/Forums/office/en-US/6bb9b40f-b794-41ce-93b4-711e77c53607/gal-default-adress-book-gpo.

    After changing the HEX key it seems no luck. Can you advise me what could be wrong? or can you modify it for use with Outlook 2010/2013

    Thanks & Regards

    Edith

    ReplyDelete
    Replies
    1. Yeah, Ever since Outlook 2010, the hex isn't working for me either. Doing a reg-dump before and after setting the default gal, it LOOKS like it should work, but haven't had any luck setting it.

      Delete