Powered by System Center
Posts tagged Powershell
Windows 8 Storage and Hyper-V – Part 2: VHDX and PowerShell
Jan 24th
This blog is part of a series that started with Windows 8 Storage and Hyper-V Part 1 – Introduction:
http://www.hyper-v.nu/archives/hvredevoort/2012/01/windows-8-storage-and-hyper-v-part-1-introduction/
VHD HISTORY
If you have been working with any of the Microsoft virtualization products, you are familiar with the Virtual Hard Disk format. VHD was introduced with Microsoft’s acquisition of Connectix and their Virtual PC product in 2003. Seven years ago Microsoft decided to make the VHD Image Format Specification available to third parties under the Microsoft Open Specification Promise.
In June 2005 Microsoft promised that the VHD file format would have a future well beyond the then prevalent virtualization products ….. and boy did they keep their promise!
The Microsoft VHD file format specifies a virtual machine hard disk that can reside on a native host file system encapsulated within a single file. The format is used by Virtual PC 2007, Virtual Server 2005 R2 and Hyper-V and the format will be used by future versions of Microsoft Windows Server that includes hypervisor-based virtualization technology. Beyond that, the VHD format is broadly applicable, because it is agnostic to the virtualization technology, host operating system, or guest operating system with which it is used.
Customers and partners who invest the VHD file format will have a clear path forward to future Windows virtualization technologies. In addition, Microsoft plans to design its systems management tools around the VHD file format for improved patching and manageability.
Since the release of Windows 7 and Windows Server 2008 R2, the VHD format became even more versatile when Microsoft promised not only to standardize the variety of container files, but also introduced native VHD. This technology made it very easy to boot from VHD and have multiple operating systems on one machine. Since then VHD’s could not only be created via the Hyper-V manager but also via the inbox Disk Manager and Diskpart. Because the VHD format was opened up a multitude of VHD tools surfaced (vhdtool, disk2vhd, wim2vhd and many more). There was no easy way to just mount the VHD from the command line so 3rd parties jumped on this as well. I should not forget to mention James O’Neill’s awesome Hyper-V PowerShell Management Library which he created when he still worked for Microsoft.
The VHD related commands in that library are:
Get-VHDDefaultPath, Get-VHDInfo, New-VHD, Compact-VHD, Test-VHD, Convert-VHD, Merge-VHD, Mount-VHD, Unmount-VHD
VHDX
During the \\build conference we learnt that Microsoft will introduce a new advanced version of the Virtual Hard Disk format called VHDX in Windows 8 (both client and server). What do we currently know about this VHDX?
How to Boot from VHD with Windows 8 Developer Preview
Sep 15th
I received a tweet from Jeffery Hicks that many of you want to know how I did the boot from VHD with Windows (Server/Client 8. Here we go!
How to defrag a Hyper-V R2 Cluster Shared Volume
May 31st
Recently I was asked to describe the correct procedure for defragmenting Cluster Shared Volumes on a Hyper-V R2 cluster. This is not really a very complicated task but if you have never had the opportunity to give it a try, this blog post will offer you the exact steps using PowerShell.
Case
Let’s start with a case description: the System Center Operations Manager Windows Management Pack is reporting “Logical Disk Fragmentation Level is high” for your Hyper-V R2 servers.
A Cluster Shared Volume (CSV) contains the configuration, virtual hard disk and snapshot files of multiple Hyper-V guests. Notably fragmentation of the large VHD files deserve your attention.
Fragmentation of these files can become a problem because the disk head needs to use an increasing number of seeks, lowering the throughput and thus the perceived performance of the guest as a whole.
On the other hand, NTFS has become more and more efficient in recent OS versions and fragmentation need not always have a severe impact on performance.
Analysis
CSV is a distributed orchestration layer on top of NTFS (implemented as a file system filter driver) and for fragmentation it takes advantage of all the NTFS techniques. The advantage of this design is that all disk management tools which have been written for NTFS continue to work, including a variety of defrag tools.
Hyper-V R2 more proficient in Linux
May 16th
Today at TechEd 2011 in Atlanta we learnt that Microsoft now officially supports CentOS. CentOS is a popular free Linux distribution and is among the top three most popular ones.
CentOS has been added to the list of formally supported Linux Distributions. The others are SUSE Linux Enterprise (v10 and v11) and Red Hat Enterprise Linux 5.2 and up. With the added support for CentOS, Windows Virtualization becomes even a better candidate for mixed Windows-Linux environments.
Many other Linux distributions can be easily integrated into a Hyper-V R2 environment since Microsoft submitted the code for the Hyper-V integration components. These additions enable native Hyper-V support for synthetic devices (video, network, mouse), multi-processor support and graceful shutdown of Linux VM’s.
In this blogpost Ben Armstrong explains how to install Ubuntu Server 10.10 on Hyper-V.
Another nice announcement was made by Yusuf Öztürk from Istanbul who developed a PowerShell based new functionality for Linux virtual machines on Hyper-V: Set-LinuxVM
What you can do with Set-LinuxVM?
- Unattended IP, Hostname and DNS configuration for Linux VMs
- Automatic Linux integration components installation
- Multi Distro Support: Debian, Ubuntu, Centos, Fedora, Redhat and Suse
- Automatic CPanel installation for Redhat and Centos
- Linux VM Template support (Use Skip for EnableLIC switch
- Hyper-V support! You don’t need SCVMM to use this script.
- Multiple Hyper-V and SCVMM host support.
- Automatic Emulated NIC to Synthetic NIC support
- No need to internet connection (SSH access etc.) or additional changes on VM.
- Custom Answer File support! You can execute your own scripts.
SCVMM 2012 – Out of Band Management (OOB)
Apr 14th
As I wrote earlier in my blog on Deep Storage Integration in VMM 2012, Microsoft decided to embrace standards as much as possible in SCVMM 2012. This is also the case in the area of Out of Band Management (OOB). Microsoft supports several standards based options:
OOB is of course intended to take control of the bare metal machine using some kind of baseboard management controller (BMC). In the HP world we know OOB very well by the name of Insight Lights Out (iLO2 and iLO3). Dell has a BMC called DRAC which stands for Dell Remote Access Controller. IBM has a Remote Supervisor Adapter or RSA. OOB can serve several purposes. One is power state control (query status, power on and power off) but also to collect information about the server hardware (SMBIOS GUID, Manufacturer, Model, AssetTag, Serial Number) or to collect system hardware logs. The ultimate goal is to leave the bare metal untouched, yet under your total control.
We can think of several scenarios:
-
Bare Metal Deployment
-
Dynamic Optimization
-
Power Optimization
The Out of Band Management interface in SCVMM 2012 is fully extensible and offers custom OOB Configuration Providers. Here is an example of such a provider in Powershell.
How to check the version of the Integration Components
Apr 1st
In a previous post of mine about the importance of Integration Components I’ve explained why it is so important to install Integration Components. So keep in mind that when you update your Hyper-V host you also update the Integration Components. If you would check for a succesful update then you need to check te version of the Integration Components software. This can be done very easily.
Check Integration Components on Host and Guest
Feb 10th
This a repost of an older posing I’ve done before, on the Wortell blog, which I would like to share with you in case you didn’t already read it ![]()
SP1 for Windows Server 2008 R2 has been release for RTM. On February 16 it will be available to current customers of the Windows Volume Licensing program, as well as subscribers to Microsoft Developer Network (MSDN) and TechNet. On February 22 it will be available to all customers through Windows Update and will also come preinstalled on new servers ordered.
With the release of ths SP1 for Windows Server 2008 R2 you might want to check your Integration Components on all you VM’s and Hyper-V nodes.
Inspired by this blog “A script to check the Integration Services Version on Hyper-V Host and Guests” and this blog “Hyper-V Integration Components version list table” the script below was created. The script mentioned in the first blog can only be executed on the host itself or via a PSSession on a remote host but is always one host at the time.
When using this script it is possible to use two different kinds of arrays. The first is a set of predefined hosts containing Hyper-V, the second is an OU in which all the Hyper-V hosts are located. To use the first type of array you need to adjust the script around line 29. When using the array based on the OU you don’t need to change the script.
The script has been tested on Windows Server 2008 R2 and Windows 7. It uses WMI so please make sure your firewall is setup correctly.
# Specifies hosts to query.
# When using a small array.
# $hosts = @(”, ”)
# When using a specific OU.
import-module activedirectory
$hosts = Get-ADComputer –filter * -SearchBase “OU=Virtual Hosts,DC=CONSTOSO,DC=local”
# Tabel headers
Write-host ‘HostName’ ‘HosticVersion’ ‘GuestName’ ‘GuesticVersion’
# Defines import filter.
filter Import-CimXml
{
$cimXml = [XML]$_
$cimTree = New-Object -TypeName System.Object
foreach ($cimProperty in $cimXml.SelectNodes(“/INSTANCE/PROPERTY”))
{$cimTree | Add-Member -MemberType NoteProperty -Name $cimProperty.NAME -Value $cimProperty.VALUE}
$cimTree
}
# Retrieves all VMs except host itself.
foreach($hostName in $hosts)
{
# When using an small array please disable $hostName = $hostName.name
$hostName = $hostName.name
$hostSession = new-pssession -computername $hostname
$icVersionParent = invoke-command -session $hostSession -scriptblock {Get-ChildItem “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\GuestInstaller” | ForEach-Object {Get-ItemProperty $_.pspath} | select-object “Microsoft-Hyper-V-Guest-Installer-Win60-Package”}
$guests = Get-WmiObject -Namespace root\virtualization -ComputerName $hostName `
-Query “SELECT * FROM Msvm_ComputerSystem WHERE EnabledState=2 AND NOT Caption LIKE ‘Hosting Computer System’”
Remove-pssession -computername $hostname
# Processes all guests.
foreach($guestName in $guests)
{
Try {
$guestKVP = Get-WmiObject -Namespace root\virtualization -ComputerName $hostName `
-Query “ASSOCIATORS OF {$guestName} WHERE AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent” –ErrorAction Stop
$icVersionGuest = $guestKVP.GuestIntrinsicExchangeItems | Import-CimXml | Where-Object{$_.Name -eq ‘IntegrationServicesVersion’}
$ichost = $icVersionParent.’Microsoft-Hyper-V-Guest-Installer-Win60-Package’
$icguest = $icVersionGuest.Data
If ($ichost -eq $icguest)
{Write-host $hostName,$ichost,$guestName.ElementName,$icguest -foregroundcolor green}
Else
{Write-host $hostName,$icVersionParent.’Microsoft-Hyper-V-Guest-Installer-Win60-Package’,$guestName.ElementName,$icVersionGuest.Data -foregroundcolor red}
}
Catch {
Write-host $hostName,$ichost ‘Host contains no running guests’ -foregroundcolor red
}
}
}
So with this script it is possible to define an array of servers by hand or define a specific OU where all the Hyper-V hosts are located in your Active Directory.
Get memory information from host
Feb 8th
Well, here’s my first post for this Hyper-V Blog. I will start with a small one… but more is coming soon!
In this blog I will show you how you can view memory usage of virtual machine’s when you didn’t have a management tool available. We will query this information from a Hyper-V node itself. There’s a great way to do this: use PowerShell!
So first we login to the host and browse to a directory e.g. E:\Install. In this directory we will create a file named memory.ps1 (ps1 is the extension for a PowerShell script). Then we open the created file and paste the following script into it: More >







Twitter
RSS