powershell

Convert All (mail enabled distribution) Groups to Universal

We are implementing a newer version of the Quest ARS system (v 6.7) . The big different from the older version is that this one uses Exchange 2007 management tools instead of the former Exchange 2003. The big difference is now our groups need to be Universal Mail Enabled groups, instead of Globals.

This script uses the Quest ARS Powershell cmdlets to grab groups, nested or not and convert them to Universal groups.

Sort Mailboxes by Size

As part of the larger mailbox moves we're doing, I developed this short function to sort an array of mailbox objects by their size. I was hoping that by feeding Move-Mailbox cmdlet a sorted list, it would move mailboxes faster. My theory being that if I started with the Largest mailboxes first, it would only take the longest mailbox time for all the moves. By sorting the list, it appears to have cut down on the doubling up of moves..

For example if my group contains:

  • Tom = 5gb
  • Lisa = 3gb
  • Fred = 2gb
  • Bob = 10gb
  • Paul = 5mb

Move 100gb of mailboxes

We're working on load balancing our mailbox storage groups and needed to thin down a database by about 100gb of data. This simple script will move up to 100gb from one storage group to a specific other storage group.

 
#Pull all mailboxes from Source DB
$fromdb = get-mailboxdatabase -server Exch1 | ?{$_.storagegroup -match "lit hold"}
$sourcegrp = Get-mailbox -resultsize unlimited -database $fromDb

#Maximum amount of mailboxes to move.
$maxmbx = 100gb

#Some book keeping variables.
$currentsize = 0
$movegroup = @()
$index = 0
$undersize = $True

Categorized Mailbox Size Report

We're working with a few groups to implement mailbox limits. To assist their users, I've been working on a report that breaks down the users into a few basic size limits. This function takes an array of IDs (Distinguished name field required) and returns a fairly basic HTML report back.

I am using the Quest AR Powershell cmdlet to read a group membership for my source data.

For example:

 
$SourceGrp = "Finance Department"
#Read in group membership.

Get Number of Mailboxes Per Exchange server

In order to report on our current load-balancing of our mailbox servers, regularly I run a report on how many mailboxes are on each mailbox server. Typically, I'd simply run a simple one-liner like the following:

get-mailboxserver | %{$_.servername; (get-mailbox -server $_.servername -resultsize unlimited).count}

This code would take 3 to 5 HOURS to query all 20 Exchange clusters and 80k mailboxes.

Got to quit trying.

I have a number of scheduled tasks. One of those tasks queries a remote AD domain and pulls the members of a security group. These accounts would be considered the LinkedMasterAccounts for mailboxes homed on my server. I want to quickly find the mailbox for each of these remote IDs and disable/enable the activesync functionality.

The fastest command would be something like:

 
get-mailbox -filter {LINKEDMASTERACCOUNT -eq (remote ID)}

Mass Enable/Disable ActiveSync services based on Group Membership

The ISO recently found that a number of people had been using their iPhones and connecting to the Email system to check their email. This was quite a surprise and actually caused some surprised screaming by said ISO. The solution was to disable all those users that did not belong to a security group.

Get-NewMailboxes function

I am working on a script to modify all new mailboxes created within the last X days. Plan to use this to apply mailbox retention policies to these new mailboxes each evening with a scheduled script. After watching a short web seminar on powershell.com, I thought I'd create it as a function that has some required parameters.

Reference: http://www.wisesoft.co.uk/scripts/powershell_search_for_all_users_by_the...

function Get-NewMailboxes {
        <#
        .Synopsis Return all mailboxes created after a specific number of days back
       
        #>
        param (

Get DistributionGroupMember -Recurse

This is a pure Exchange 2007 cmdlet version of get-qadgroupmember -indirect. This code does not check for duplicates, so if you have the same person nested a couple times, you will get duplicate entries for them.

function Get-DLMembersRecurse ($DL) {
        $memlist = @()
        $mems = Get-DistributionGroupMember $dl -ResultSize unlimited
        foreach ($m in $mems) {
                if ($m.recipienttype -match "group") {         
                        Get-dlmembersRecurse $m.identity
                } else {
                        if (($memlist -match $m).count -eq 0) {$memlist += $m           }
                }      
        }
        return $memlist
}

Powershell - Break Down Group membership - Visual display

This script was designed to detail what groups a mailbox is member of. I didn't necessarily want a flat dump of group membership (i.e. get-qadgroupmember -indirect). I wanted something that would give a detailed break down of what groups a person belonged to, and how it flows up into parent groups.

Script uses Exchange 2007 PowerShell cmdlets + Quest Active Roles Powershell Cmdlets.

Here's what I get back from this script:
----------------
.All Staff List
..Windows Team