Month: January 2013

Get Hyper-V (Windows Server 2012) guest network configuration using WMI

If you have not seen this yet, the updated WMI namespace for Hyper-V role in Windows Server 2012 has some hidden gems. I love playing around with WMI and the changes in Hyper-V namespace had me thinking about new possibilities. Here is the first one in this series of posts on how you can extend Hyper-V management beyond what is available in the Hyper-V PowerShell module. In this post, I will show you a simple function to get the guest network configuration details using WMI. We use the Msvm_GuestNetworkAdapterConfiguration WMI class to achieve this.

In the above function, we are making use of the updated virtualization namespace root\virtualization\v2. In this function, we first get the virtual machine object:

Once we have the VM object, we retrieve the VM setting data which includes information on how many synthetic network adapters are attached, etc.

Since the above command gives us entire VM setting data and we are interested only in the synthetic adapter data, we filter this further to get only the synthetic adapters attached …

PoshUtils: Set (enable or disable) resource metering on clustered Hyper-V virtual machines

In Windows Server 2012 with Hyper-V role, we can enable VM resource metering to measure the utilization of four resource types (CPU, memory, network, and disk) of Hyper-V virtual machines. Once the resource metering is enabled, using Enable-VMResourceMetering, we can use Measure-VM cmdlet to retrieve the utilization of a VM. Now, there are Enable-VMResourceMetering and Disable-VMResourceMetering cmdlets to enable and disable resource metering on an individual VM (-VMName parameter) or a group of VM objects (-VM parameter). So, what is this clustered Hyper-V virtual machines I am referring to? Well, the two cmdlets I just mentioned aren’t cluster object aware. This means you cannot give these cmdlets a clustered group object and then enable or disable resource metering on those virtual machine objects. So, this is where the following function will help you. It takes the name of the Hyper-V cluster as an input and enable or disable VM resource metering on all the virtual machines in the given cluster. You may already know that the Get-VM cmdlet is cluster object aware. So, we can …

PoshUtils: Downloading SharePoint 2013 prerequisites for offline install

Okay, this is yet another post on downloading the SharePoint 2013 prerequisites for offline install. I am sure you have seen many and everyone has their own way. But I think none of those posts/scripts – at least the ones I read – don’t give you a unified way to download the prerequisites for all combinations of Windows Server OS and SQL Server versions. So, here is my take. The idea of this script is to use the features of PowerShell 3.0 such as Out-GridView and default parameter values to reduce the amount of code required. Note: The list of prerequisites I compiled here is what I perceived looking at technet documentation. Do let me know if I missed out anything or need to change something here. Let us see the code first.

In the above code, I am using a CSV file I compiled with all the SharePoint 2013 prerequisite information. This is the key here. You can download the CSV file here. Instead of a hash, I preferred to use a CSV file as …

Configuring anti-affinity for Hyper-V virtual machines

If you have worked on VMware, you might already be aware of a concept of DRS rules. Using DRS rules, we can create VM anti-affinity rules so that no two virtual machines hosting similar application roles run on the same ESX host. For example, when you have a virtualized SQL mirror or a virtualized SQL failover cluster, it is critical to separate the SQL virtual machines participating in the application group onto different ESX hosts. This is where we can use VMware DRS rules – “Separate Virtual Machines” rule to be specific.