Hyper-V migration

I’ve been using VMware’s Server product for a while now for virtualisation. I mainly use it for testing things, like a Linux install or a new server product from Microsoft. I’ve decided to try out Hyper-V, partly to see how it measures up and partly because I’ve been getting performance slowdowns on my VMWare VMs.

Powershell Task of the Day – Move Mailbox for all users in an Organisational Unit (part 2, Bulk move)

A follow on from the previous script was to move a larger number of users in a list of OUs. To make the task easier, I decided to automate it a bit:

$miglist = import-csv c:scriptsmigration.csv

foreach ($item in $miglist)
{
$strTargetmbx = "EXCH02" + $item.tiernumber + "-east" + $item.tiernumber + "-east"
$strReportFile = "c:scripts" + $item.name + ".xml"
Get-Mailbox -server "EXCH01" -OrganizationalUnit $item.ouname | `
Move-Mailbox -Confirm:$False -TargetDatabase $strTargetmbx -SourceMailboxCleanupOptions DeleteSourceMailbox -ReportFile $strReportFile
}

In the first line, I’m importing the contents of a CSV file that listed the OUs, a friendly name for the OU and the “tier” database those users were to go in. Iterating through the $miglist, I construct the target mailbox database name ($strTargetmbx) and report filename ($strReportFile). The Move-Mailbox command uses the -Confirm:$False switch to suppress confirmation. If this switch isn’t used, you will be prompted for confirmation at each step. The rest of the move command is pretty simple, specifying where to move to and a report filename.

Powershell Task of the Day – Move Mailbox for all users in an Organisational Unit

I needed to migrate users from one email server to a new one with more storage. These users mostly fell into neat OU grouping. To do an OU at a time, I used the following command:

Get-Mailbox -server "EXCH01" -OrganizationalUnit "domain.local/Company/State/Office/Department/Team" | `
Move-Mailbox -TargetDatabase "EXCH02StorageGroup1Database1" -SourceMailboxCleanupOptions DeleteSourceMailbox –ReportFile c:migration_report.xml

The first line gets all the mailboxes in the specified OU. Line 2 performs the mailbox move, specifying the target database and a custom report file name for the results.

Powershell Task of the Day – Get Mailbox Size For Users in an OU

During an email migration, I wanted to see how many users would be under the new limits that would be imposed on them. In most cases, the restrictions would match their location in Active Directory. So I was able to export the needed details and view them:

# Process email stats for users in the specified OU and save to CSV file

Add-PSSnapin Quest.ActiveRoles.ADManagement
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Support

if (!$args) # Empty arguments
{
write-host "You must specify correct arguments, specify the OU to check, then the file name. ie. email_stats.ps1 domain.com/OUName/OUName2 oulist.csv"
}

write-host "Processing based on arguments..."
write-host "OU: " $args[0]
write-host "CSV: " $args[1]

$OUName = $args[0]
$FileName = $args[1]
$i=0
$strTest = "Name,Alias,ServerName,OU,TotalSize(KB)`n"

$arrMailboxList = get-mailbox -OrganizationalUnit $OUName | select name, alias,servername,organizationalunit
$arrMailBoxListCount = $arrMailboxList.count
foreach ($item in $arrMailboxList)
{
$i = $i+1
write-progress -id 1 -activity "Getting Mailbox List" -status "Progress:" -percentcomplete ($i/$arrMailboxListCount*100)
$arrMailboxStats = Get-MailboxStatistics -identity $item.alias | select displayname,totalitemsize
foreach ($stat in $arrMailboxStats)
{
$strTest = $strTest + $item.name + "," + $item.alias + "," + $item.servername + "," + $item.organizationalunit + "," + $stat.totalitemsize.value.toKB() + "`n"
}
}

Out-File -filePath $FileName -inputObject $strTest -encoding ASCII

This is my first powershell script using arguments. In this script, I was wanting to submit 2 arguments – the Organisation Unit to check and the CSV file to save the final results to. The basic work flow is to get all the users in the specified OU and then loop through the results, performing a Get-MailboxStatistics cmdlet on each. A CSV-formatted string is stored in a variable and then finally outputted to a CSV file.

Powershell Task of the Day – Bulk add to a distribution list

A follow on from the previous script, I had to then add some users to a distribution list. The following command was used:

get-user -organizationalUnit "domai.local/Company/State/OfficeLocation/Department/Team" | `
select UserPrincipalName | `
foreach { Add-DistributionGroupMember -identity "SA IP Agents" -member $_.UserPrincipalName }

Like the previous script, line 1 is getting users from he specified OU. In this operation, we really only need the User Principle Name. Line 3 iterates through the results, using the Add-DistributionGroupMember cmdlet to add the user.

Powershell Task of the Day – Bulk Email Account Creation

A new office requires a large number of email accounts to be created. Fortunately, the users already had Active Directory accounts and they were in the same organisational unit. I used the following Powershell command to create the users:

get-user -OrganizationalUnit "domain.local/Company/State/OfficeLocation/Department/Team" | `
where-object {$_.RecipientType -eq "User"} | `
Enable-Mailbox -database "EXCH01StorageGroup1Database1"

Line 1 gets the users in the specified organisation unit, while line 2 narrows the results to just User objects. Line 3 performs the actual mailbox creation. 86 users were created with effectively one line of code.

Update on the armory viewer

I haven’t had the opportunity to do a lot of work on the Warcraft armory viewer (http://www.jpboyce.org/armory/) as I’ve been changing servers recently. I have added a couple tweaks. I’ve updated the link the site calls to the updated armory domain name. Also I’ve added an “Upgrade” link that uses the excellent Lightwindow javascript/widget/thingy by Kevin Miller. Any suggestions or comments, feel free to post them.

Armory Reader

The World of Warcraft armory (armory.worldofwarcraft.com) is a nice tool  or looking up characters. But I never liked the way it’s setup, where you have to mouse over every item slot to see the item details. Blizzard were nice enough to make the armory use XML. So I wrote a little ASP.NET application to take that XML and reformat the output in a more lightweight combined fashion. It’s available at www.jpboyce.org/armory

Still on the to do list:

  • Enchants and socketed gems on gear
  • More character details (resistances, etc)
  • Layout cleanup
Bitnami