Skip to content


Tag: Powershell

Shrinking disks on your Hyper-V guests

A few of my guests run on SSD drives. Occasionally I reclaim diskspace by defragmenting and compacting the VHD;s. I have managed to free up to 20GB diskspace on a single guest, which is pretty much SSD wise. However, first of all, you should consider before putting R/W intense operations, such as VMs, on your SSD;s.


Since this is a process that will take quite some time I wanted to make it as automated as possible.


1. Defrag with Raxco perfect disk. This script is run remotely on the target machines. Errorhandling is omitted for readability.


2. Compact VHD:s. Run in powershell on the Host. Make sure the actual VM is turned off.


There are a few options for you to get ActiveSync statistics from an Exchange 2010.

First some Powershell and then Log Parser if you don’t want to dig into the IIS-Logs yourself 😉


Get-ActivesyncDevice: Retrieve list of devices that have ActiveSync partnerships.


Get-ActiveSyncDeviceStatistics : Returns statistics about each device.


Export-ActiveSyncLogs : Analyzes IIS-Logs and creates reports in CSV-format.

Export-ActiveSyncLogs will generate six CSV files: “Users.csv”, “Servers.csv”, “Hourly.csv”, “StatusCodes.csv”, “PolicyCompliance.csv” and “UserAgents.csv”.

The IIS-Logs also hold username and IP-adress for the mobile device. Useful to know when the firewall guys come running down the corridor with the IP-adress for a misbehaving sync 🙂

If you have several CAS servers, you need to process the IIS-logs from each one of them.



LogParser 2.2 :

LogParser Studio:





LogParser Studio is also able to export the query as a Powershell script.



Import AD powershell module if not already loaded


Create an AD group

-groupscope : Domainlocal(0), Global (1), Universal (2). ( LDAP property “groupType”)
-instance ADGroup : Use AdGroup as template

Example 1:

Example 2:


Create a new Organizational Unit



Get the AD distinguished name

Move mailbox

Move Arbitration Mailboxes


Unlike VMWare or Virtual PC, Hyper-V does not have a functionality to share folders between the host and guest.You have to rely on a network connection to share folders or utilize a RDP session to transfer data.

There has been an update for Hyper-V called “Enhanced Session Mode” but its only available if your host is a Windows Server 2012 R2 and your guest is either a Windows Server 2012 R2 or a Windows 8.1. The Enhanced Session mode connection uses a RD session via the virtual machine bus (VMBus) and does need a network connection.

If you have network access, or can use the Enhanced Session Mode, you are probably fine… but my Hyper-V host is on an isolated network and I can not use the Enhanced Session Mode since my guests mainly consist of Windows 2008 R2 Servers.

However. It is possible to make a snapshot/checkpoint to export the data, or mount/dismount disks. There is plenty-a-lot of information about this on the net.

My solution for transferring data to the host is by scripting .ISO images(mkisofs) and use powershell to mount them.


(Un)Mount the CD/DVD image on your Hyper-V guests.

Get information of currently mounted images:







Install Exchange 2010 Management tools on Windows Server 2008R2

Manual installation:
Install the following prerequisite components:
.Net Framework 3.5 (Net-Framework-Core)
IIS6 Management Console (Web-Lgcy-Mgmt-Console)
IIS6 Metabase Compability (Web-Metabase)

Launch Exchange (sp3) setup CD and select Custom Exchange Server Installation.


…and same with Powershell: