PowerCLI – Windows VM Partition Alignment
In an effort to keep my blog from becoming an wasteland, I bring you a modified version of a script I found here that enumerates virtual machines and then does a WMI call against each one to determine if the partition is aligned.
The original version only does it for one value (65536) - this one does it for both 65536 and 32768.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | $myCol = @() $vms = get-vm | where {$_.PowerState -eq "PoweredOn" -and ` $_.Guest.OSFullName -match "Microsoft Windows*" } | Sort Name foreach($vm in $vms){ $wmi = get-wmiobject -class "Win32_DiskPartition" ` -namespace "root\CIMV2" -ComputerName $vm foreach ($objItem in $wmi){ $Details = "" | Select-Object VMName, Partition, Status if ($objItem.StartingOffset -eq "65536"){ $Details.VMName = $objItem.SystemName $Details.Partition = $objItem.Name $Details.Status = "Partition aligned" } elseif ($objItem.StartingOffset -eq "32768"){ $Details.VMName = $objItem.SystemName $Details.Partition = $objItem.Name $Details.Status = "Partition aligned" } else{ $Details.VMName = $objItem.SystemName $Details.Partition = $objItem.Name $Details.Status = "Partition NOT aligned" } $myCol += $Details } } $myCol | Export-Csv -NoTypeInformation "C:\Temp\PartitionAlignment.csv" |
There are several things you will need to know about this script prior to running it:
- This requires PowerCLI (from vmware.com).
- Because this script uses WMI, it will use the credentials of the user you are logged in as. You can use something like this if you need to specify credentials.
- If you want to add additional offsets, simply copy the elseif statement and paste it below the } for 32768.
Hope it helps!
Need to move mailboxes quickly?
I'm supposed to have this week off for our company's annual winter break, but like most sysadmins I will end up having to work when everyone else doesn't.
I get the pleasure of moving about 250GB worth of mail around in an effort to get rid of 2 corrupted mailstores. Mailstores that even Microsoft can't fix. I have spent about 15 hours on the phone with Microsoft since Friday - it is now Monday. The original call was to remove a couple of mailboxes that weren't being deleted normally. Somehow a user (it's always the users fault... right?
) of mine managed to create a looped folder in her deleted items box. Imagine a folder structure like this:
Deleted Items
A+
B+
A+
B+
A...B...A...B... for eternity.
I tried everything. Moving the mailbox, disconnecting and reconnecting the mailbox, mfcmapi, pfdavadmin, screaming and pounding on the keyboard. Nothing worked. Microsoft couldn't figure it out either. I now believe that this may be the cause of my latest BackupExec issues alluded to in my previous blog post- a belief that is strong enough that I have actually halted publishing it until I'm sure. Don't get me wrong though, Symantec hasn't made a good product in years...
Microsoft's solution is the same one that I had come up with before I had called them. I have to move all of my mailboxes off the affected mail stores. Which means about 400 mailboxes and 250GB.
Not wanting to sit there and manually move one mailbox at a time, I decided to seek out a powershell script to do the moving for me. I needed something that could read from a CSV file and do a multithreaded (more than one a time) moves. The multithreaded part turned out to be the big problem. Writing a powershell script to move 1 mailbox at a time is something that takes no real effort, but multithreaded requires a little bit more complexity. Since I'm never one to reinvent the wheel, I turned to Google and stumbled (after way too much keyword manipulation) to find a MSExchangeTeam blog article on it.
It allows you to import a CSV file with the following format (I'll save you from trying to find it in the documentation):
Identity,targetmbserver,targetmbsg,targetmbdb
Bob Smith,mailserver,storagegroup,mailboxdatabase
Jane Doe,mailserver,storagegroup,mailboxdatabase
It will then move 4 at a time and display the progress. Perfect. Now if only they could move faster...