Archive | August, 2011

PowerShell to assign Exchange 2010 Retention Policies based on AD group membership

In exchange 2003 we maintained a 6 month and 12 month purge policy that was applied based on group membership. I described that configuration here. I wanted to migrate our purge policies to the new 2010 Recipient policies. I needed to find the members of an AD group and assign a retention policy to their mailbox. Here is my script:

Get-ADGroupMember mailboxpurge-6m | foreach {
if ((get-mailbox $_.samaccountname).ServerName -eq "server01" -OR (get-mailbox $_.samaccountname).ServerName -eq "server02" )
write-host "User" + $_.samaccountname + "'s current policy is: " + (get-mailbox $_.samaccountname).RetentionPolicy
set-mailbox $_.samaccountname -RetentionPolicy 6MonthPurge

Retention Policies in Exchange 2010

I have to say that retention policies in Exchange 2010 are a bit confusing. I understand that they are more powerful and it gives users more control in marking items that should not be purged. But, it is just easier in exchange 2003, you can select the folders you want and select “delete immediately”. For users created folders, you select “all other mail folders”

In 2010, it took me a while to realize that, to create a purge policy that only removed mail items, I needed to create Calendar, Contacts, and Notes policies and “Disable this Tag” .

Get-RetentionPolicyTag Calendar-NeverDelete | fl Name,MessageClass, RetentionEnabled,Type
Name             : Calendar-NeverDelete
MessageClass     : *
RetentionEnabled : False
Type             : Calendar

. . .  and in the gui:

That seems backwards to me.

Scheduled PowerShell script to resume Mailbox Moves (New-MoveRequest)

Moving mailboxes from 2003 to 2010 is easy, but there is not a “Gui” to schedule it. So I created the following PowerShell script to find all the suspended MoveRequest(s) with the correct date, and resume them.

$TodaysDate = (get-date).day.ToString() + (get-date -format MMMM)
Get-MoveRequest -MoveStatus Suspended | Get-MoveRequestStatistics | Where {$_.BatchName -like "*$TodaysDate*"} | Resume-MoveRequest

Next I create a scheduled task with the following command to run a script with the code above:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; c:\Scripts\MailboxMove.ps1"

Now when I create a New-MoveRequest,

New-MoveRequest -Identity username -TargetDatabase MailboxDatabase02 -BatchName "19August" -BadItemLimit 10 -Suspend

I know that a scheduled task will resume the move a the correct time.

To monitor progress, I have been using this script:

Get-MoveRequest  | Get-MoveRequestStatistics | ft -auto alias,Status,TotalMailboxSize,PercentComplete,TargetDatabase,TotalInProgressDuration,BytesTransferred,BatchName

Force the Light Version of Exchange 2010 OWA on a Cisco ASA WebVPN with SSO

We have a Cisco ASA in front of our Exchange 2010 OWA application. We needed to create a “bookmark” to point to OWA. Since we are using Forms based authentication, we did not want users to have to re-login after just logging into the ASA. I found this link on how to setup the Bookmark for SSO and Exchange 2010 OWA. We wanted to take it a step further and force the “Light version” of OWA until we could upgrade the ASA code (we are using an older rev and OWA JavaScript is not working correctly). To do this you need to change the “flags” post value to “1”.

So, to “Force the Light Version of Exchange 2010 OWA on a Cisco ASA WebVPN with SSO” you need to do the following:

Configuration -> Remote Access VPN -> Clientless SSL VPN Access -> Portal -> Bookmarks -> Add/Edit your Bookmarks
URL: https :///owa/auth/owaauth.dll

Advanced Options: Post
destination : https:///owa/
flags : 1
forcedownlevel : 0
trusted : 0
username : <yourdomain>\CSCO_WEBVPN_USERNAME
SubmitCreds : Login
isUtf8 : 1

Fun with Toshiba IPT 2010 phones and NAT

We have a Toshiba phone system in our office. I don’t know much about it, because it is run by the very capable @mattsix, but today I jumped and did a little troubleshooting.

The reoccurring issue we had, was that a remote phone would connect to the IPU, ring, but there would be no audio. We were testing with an Airport Extreme hooked up to a DSL modem and an IPT 201-SD hooked to that.

First, we found this thread. We checked the “NAT/No Peer to Peer ” settings and they seemed right. Then I cam across this post. Wait, what? There are different types of NAT? I did not know that. As soon as we moved the Airport Extreme out of the mix, and put in a D-Link gaming router, the audio started working.

I guess the Airport Extreme is using Symmetric NAT and the D-Link is using a more capable NAT.

Mystery solved? We shall see.

Update: I found this in the “Starta CIX General Description

The Strata CIX supports the use of IP telephones that are behind NAT firewalls.

Symmetric — At this time these routers may cause unreliable service or cause unwanted symptoms. These routers are not compatible with Strata CIX and Strata Net IP configurations

BASH script to email if WordPress plugins or themes need updating

This one took me all day. But I got it. I wanted to have a script that could look through all WordPress sites and find if there are outdated themes or plugins. All I need to do is slap it into a cron job and I am good to go!

Here is the BASH code to do it.



for installpath in $(find /var/www -name wp-config.php)
cd $(dirname $installpath)

THEMENEEDED=$(php -r 'require_once("./wp-load.php");
$new = get_site_transient("update_themes");
echo count($new->response);')

if [ ! $THEMENEEDED = 0 ]; then
UPDATESNEEDED="$UPDATESNEEDED \n Site $installpath needs $THEMENEEDED theme(s) updated"

PLUGSNEEDED=$(php -r 'require_once("./wp-load.php");
$new = get_site_transient("update_plugins");
echo count($new->response);')

if [ ! $PLUGSNEEDED = 0 ]; then
UPDATESNEEDED="$UPDATESNEEDED \n Site $installpath needs $PLUGSNEEDED plugin(s) updated"

if [ -n "$UPDATESNEEDED" ]; then
echo -e "$UPDATESNEEDED" | mail -s "Updates are needed"

I have been needing this script for a while.

Powered by WordPress. Designed by WooThemes