Hits: Windows Server 2008 (R2) blog by Kurt Roggen [BE]

The new PowerShell cmdlets for Hyper-V (by James O’Neill) are implemented in the form of a PowerShell version 2 module which is distributed as a single zip file from http://PShyperV.codeplex.com.

A previous version was implemented for version 1 of PowerShell and remains available on CodePlex. The previous version will also work on PowerShell V2, but the new version will not work on PowerShell V1.
Both versions work with the original release of Hyper-V and the R2 release.

The library uses 31 different verbs and 69 different nouns (2139 possible combinations)

image

To install the Hyper-V module, copy the contents of the “HyperV_Install” folder (inside the zip file) to a new folder “%systemdrive%\Windows\System32\WindowsPowerShell\v1.0\Modules\HyperV”

image

To find the Hyper-V module, from PowerShell, type

Get-Module -List

image
Notice the HyperV module is picked up automatically by PowerShell.

To import the Hyper-V module, from PowerShell, type

import-module HyperV

To find out which commands are available through the module, from PowerShell, type

get-command -module HyperV

To get help or more detailed information about a specific cmdlet, from PowerShell, type

get-help <cmdlets>

Some more examples:

Connecting to a VM
New-VMConnectSession

Discovering and manipulating Machine states
Get-VMState , Set-VMState , Convert-VmState, Ping-VM , Test-VMHeartBeat, Shutdown-VM , Start-VM, Stop-VM, Suspend-VM, Get-VMKVP, Add-KVP, Remove-KVP, Get-VMJPEG

Backing up, exporting and snapshotting VMs
Export-VM , Import-VM, Get-VMSnapshot, Choose-VMSnapshot , Apply-VMSnapshot , New-VMSnapshot ,Remove-VMSnapshot, Rename-VMSnapShot, Update-VMSnapshot, Get-VMSnapshotTree, Get-VmBackupScript

Adding and removing VMs, configuring motherboard settings.
New-VM , Remove-VM , Set-VM , Get-VMCPUCount, Set-VMCPUCount, Get-VMMemory, Set-VMMemory, Set-VMSerialPort

Manipulating Disk controllers, drives and disk images
Get-VMDiskController
Add-VMSCSIController , Remove-VMSCSIcontroller
Get-VMDriveByController , Add-VMDRIVE , Remove-VMdrive
Get-VMDiskByDrive, Add-VMDisk , Set-VMDisk, Get-VMDisk
Get-VMFloppyDisk , Add-VMFloppyDisk
Add-VMNewHardDisk

Manipluating Network Interface Cards
Get-VMNic , List-VMNic , Choose-VMNIC, Add-VMNIC, Remove-VMNIC , Set-VMNICAddress , Set-VMNICConnection , Get-VMNicport,
Get-VMNicSwitch, Choose-VMSwitch, New-VMSwitchPort, Get-VMByMACaddress, Choose-VMExternalEthernet,
New-VMExternalSwitch, New-VMInternalSwitch, New-VmPrivateSwitch

Working with VHD files
Get-VHDDefaultPath, Get-VHDInfo, New-VHD, Compact-VHD, Test-VHD,Convert-VHD,Merge-VHD,Mount-VHD, Unmount-VHD

 

Download Hyper-V R2 PS Library documentation here

Download Hyper-V R2 PS Library here

VMM provides PowerShell cmdlets that allow you to perform simple administrative tasks in an automated way or that you can use together with other cmdlets or command-line elements, to perform more complex tasks (eg: rapid provisioning).

Jobs are displayed for each action performed in VMM and can be viewed directly in the VMM administrator console. VMM provides a central place for monitoring actions taken in VMM with Jobs.
You have the ability to sort, filter and group jobs to easily find jobs that meet specific criteria.
Each failed job has troubleshooting tips to help you resolve failures. By integrating jobs with the VMM console, you have a single place to monitor your virtual environment.

VMM provides three ways to get information about jobs:

  • Jobs view
  • Jobs window (VMM toolbar)
  • Latest Job tab (on a host or VM)

image

By default, VMM maintains the job history for the past 90 days in its SQL database (TaskTrail table) and cleans up using its internal Garbage Collection process.
The size of the VMM database is impacted by the number of jobs (daily) run and the number of days these jobs are kept.

To change the interval of the garbage collection process and to (automatically) purge the Job History in VMM 2008, add the “TaskGC” registry key to HKLM\Software\Microsoft\Microsoft System Center Virtual Machine Manager Server\Settings\SQL.  The REG_DWORD value controls the number of days that events are stored in the SQL database.

Once you restart the VMM service jobs will be automatically be purged from the database.

By default, the garbage collection job runs every 20 hours and will read the TaskGC value to start the removal process of jobs above this limit.

NOTE: Microsoft recommends for VMM implementations over 150 hosts, that you enable server-optimized garbage collector (GC) on the VMM server instead of the default workstation garbage collector.
This can significantly reduce the CPU utilization on the VMM server and improve your performance for parallel VMM operations.

To enable the server-optimized garbage collector on the VMM server, create a file that is named vmmservice.exe.config - using the content below - and then for VMM 2008, place it into the %SYSTEMDRIVE%\Program Files\Microsoft System Center Virtual Machine Manager 2008\Bin directory on the VMM server, or for VMM 2008 R2, place it into the %SYSTEMDRIVE%\Program Files\Microsoft System Center Virtual Machine Manager 2008 R2\Bin directory on the VMM server.

Content of the vmmservice.config file
<configuration>
     <runtime>
           <gcServer enabled="true"/>
     </runtime>
</configuration>

 

Related reading:

The other day, I got asked which ports VMM 2008 (R2) uses/needs.
Well, here‘s a list of TCP/IP ports SCVMM needs to talk to various system components:

image

  • VMM Server
    • 80 (HTTP, WinRM) - Mgmt
    • 443 (HTTPS, BITS) - Data
    • 8100 (WCF Connections to PowerShell or VMM Administrator Console)
  • Library Server
    • 80 (HTTP, WS-MAN)
    • 443 (HTTPS, BITS)
  • VMM SQL Server
    • 1433 (Remote SQL instance connection)
    • 1434 (SQL browser service) - only needed for initial setup
  • VMM Self-Service Web Portal
    • 80 (HTTP) or 443 (HTTPS)
  • VM Host: Hyper-V or Virtual Server
    • 80 (HTTP, WS-MAN)
    • 443 (HTTPS, BITS)
    • 2179 (VMConnect on Hyper-V hosts for single-class console view)
    • 3389 (RDP)
    • 5900 (VMRC on Virtual Server hosts)
  • VM Host: VMware ESX hosts
    • 22 (SSH for SFTP files to/from ESX hosts) - this is only used for ESX host version 3.0 and 3.5 (not needed for 3.5i)
    • 443 (HTTPS for calling VI Web Services APIs)
  • P2V Source
    • 80 (HTTP, WinRM) - Mgmt
    • 135 (DCOM)
    • 443 (HTTPS, BITS) - Data
  • VMware VirtualCenter server
    • 443 (HTTPS for calling VI Web Services APIs)

For more information:  VMM Ports and Protocols

The VMM server initiates a series of specific refresh jobs at specific intervals.  Here’s an overview of what happens when…

Host Refresher
Runs every 30 minutes on every host (with time lags) and updates host properties. It also updates disk/SAN and host network (NIC / virtual switch) information. It does not check any VM related properties or performance counters on hosts. It can be manually triggered on the UI or through PS cmdlet Refresh-VMHost.

VM Heavy Refresher
Runs every 30 minutes on every host and also runs whenever a VM is clicked on (or when you call Refresh-VM PS cmdlet). It updates all VM properties, resource pools, clustering information for this VM and snapshots, but it does not update VM performance counter info.  It can be manually triggered on the UI or through the PS cmdlet Refresh-VM.

VM Light Refresher
Runs every 2 minutes on every host that is currently in the VMM database.
This refresher does the following:

    - Checks the host state (to see if the agent is running or the agent is down) and virtualization software status
    - Syncs the state of a VM
    - Marks VMs as missing 
    - Imports new VMs created outside of VMM (when VMM detects a new VM created, it is imported into VMM and launch the heavy refresher for this new VMs)

Cluster Refresher
Runs every 30 minutes and refreshes all cluster properties (including bringing in newly added nodes or taking our removed nodes). It can be manually triggered on the UI or through PS cmdlet Refresh-VMHostCluster.

Library Refresher
Runs on user configurable schedule (By default: every 1 hour, increments by 1 hour intervals and can be turned off completely) and updates the library shares info and metadata about library objects. It can be manually triggered on the UI or through PS cmdlet Refresh-LibraryShare.

Performance Refresher
Runs every 9 minutes on a host or whenever there is any state changing operation on the VM (start/stop/save/etc.). It collects performance counter information of both the host and all the VM’s on a given host.  The performance data is used for intelligent placement and the star rating calculation.

VirtualCenter Refresher
Runs every 30 minutes and refreshes VC properties, ESX hosts and resource pools that are managed by this VC. It can be manually triggered on the UI or through PS cmdlet Refresh-VirtualizationManager.

User Role Refresher
Runs every 30 minutes and updates user role properties.

PRO Tip Refresher
Runs every 30 seconds. It looks for PRO specific alerts in Operations Manager and reconciles the PRO tips in our DB against the data that is brought back from OpsMgr.  This refresher cannot be manually triggered.

 

More information: VMM Blog All about refreshers

Related reading:

Hyper-V provides virtual machines with a pool of Media Access Control (MAC) addresses when Hyper-V is installed. Hyper-V has an algorithm to avoid duplicate MAC addresses on a single host, but not across multiple hosts. A crucial element in this algorithm is the Hyper-V host IPv4                                                                                                                              address (last 2 octets).

This article describes how MAC address pools work in Hyper-V, how it is possible to accidentally deploy hosts with duplicate MAC address pools, how to modify the default MAC pool and how using SCVMM 2008 to manage your Hyper-V hosts can prevent duplicate MAC addresses. 

The table below shows how to identify VM created with Hyper-V or VMM based in the MAC Address identifier.

VMs created with Hyper-V 00-15-5D
VMs crated with VMM 00-1D-D8

NOTE: Since Windows Server 2008 R2 Hyper-V, you can change this MAC address pool from the Hyper-V Manager console instead of going through registry keys (MinimumMacAddress/MaximumMacAddress).

image

Learn more on how Hyper-V uses a MAC pool per Hyper-V host  and how VMM uses a MAC address pool for all VMHosts (Hyper-V, Virtual Server, VMware ESX).
For more information: VirtualizationAdmin.com: Dealing with MAC addresses in Hyper-V and VMM

Active Directory Web Services (ADWS) is a (new) windows service that enables remote management of any local directory service instance using WS-* (Web Services) protocols and is only present on domain controllers running Windows Server 2008 R2.

In a non-Windows Server 2008 R2 domain controller environment, the Active Directory Management Gateway Service enables administrators to use the Active Directory module for PowerShell and/or the “Active Directory Administrative Center” (ADAC) snapin - built on-top of PS and only available and running on Windows Server 2008 R2 or Windows 7 - to access or manage directory service instances that are running on Windows Server 2008 or Windows Server 2003 operating systems in the list below.

The Active Directory Management Gateway Service provides a web service interface to Active Directory domains and instances of Active Directory Lightweight Directory Services (AD LDS) or Active Directory Application Mode (ADAM) that are running on the same server as the Active Directory Management Gateway Service.

You can download and install the Active Directory Management Gateway Service on servers and domain controllers running the following operating systems:

  1. Windows Server 2003 R2 with Service Pack 2 (SP2)
  2. Windows Server 2003 SP2
  3. Windows Server 2008
  4. Windows Server 2008 SP2

The ADGMS provides the same ADWS functionality in a non-Windows Server 2008 R2 domain controller environment, hence its name “Management Gateway” service.

Here’s how the architecture looks like.
image

ADWS manages all directory service instances running on the server, including Domain Controller, Global Catalog and ADLDS instances.
The AD Web Service is implemented using WCF (Windows Communication Foundations) and listens on the registered TCP port 9389.

So in this way, you could start using the PowerShell modules for Active Directory from your Windows 7 workstation to automate some directory operations.

To get a list of available PS modules, use the cmdlet Get-Module.

PS:\> Get-Module –ListAvailable

To use a module, use the cmdlet Import-Module

PS:\> Import-Module ActiveDirectory

To get the cmdlets imported from a module, use the Get-Command cmdlet with the –Module parameter

PS:\> Get-Command –Module ActiveDirectory

image

To get a better understanding about the Active Directory PowerShell model, have a look below:

image

NOTE: You can install the Active Directory Management Gateway Service on writable domain controllers as well as read-only domain controllers that are running Windows Server 2008 or Windows Server 2008 SP2.
After it is installed on any of these operating systems, the Active Directory Management Gateway Service runs as the Windows Server 2008 R2 Active Directory Web Services (ADWS) service and provides the same functionality.

For more information about ADWS, see What's New in AD DS: Active Directory Web Services

NOTE: Installing the Active Directory Management Gateway Service on your Windows Server 2008–based or Windows Server 2003–based servers does not make it possible for you to install the Active Directory module or the Active Directory Administrative Center (which is available only on Windows Server 2008 R2 or Windows 7 operating systems) on these servers.

If the Active Directory Management Gateway Service on your Windows Server 2008 or Windows Server 2003 server is stopped or disabled, client applications, such as the Active Directory module or the Active Directory Administrative Center will not be able to access or manage any directory service instances that are running on this server.

Download ADMGS here

For more information:

This 211-pages document describes the new and changed functionality and features available in Windows Server 2008 R2. The Windows Server 2008 R2 operating system includes changes to Windows Server 2008 features and technologies that help improve the security of computers running Windows Server 2008 R2, increase productivity, and reduce administrative overhead.

Download here

 

Related reading:

Windows Server 2008 includes a command-line utility called ServerManagerCmd.exe that allows administrators to configure roles, role services and features from the command line. Beginning with Windows Server 2008 R2, ServerManagerCmd.exe has been deprecated.  When you attempt to run servermanagercmd.exe you will receive the following message:

“Servermanagercmd.exe is deprecated, and is not guaranteed to be supported in future releases of Windows. We recommend that you use the Windows PowerShell cmdlets that are available for Server Manager.”

Servermanagercmd.exe has been replaced with new PowerShell Server Manager cmdlets (pronounced ‘command-lets’). Before we can use these new cmdlets we must first import them as a PowerShell module.  There is a Powershell module called “ServerManager”.

Open an elevated PowerShell command prompt and enter the following command:

import-module ServerManager

There are 3 new PowerShell cmdlets:

get-command -module ServerManager

CommandType     Name
-----------     ----
Cmdlet          Add-WindowsFeature
Cmdlet          Get-WindowsFeature
Cmdlet          Remove-WindowsFeature

Their corresponding ServerManagerCmd.exe equivalents [in brackets]:

Add-WindowsFeature [servermanagercmd.exe –install]

Get-WindowsFeature [servermanagercmd.exe –query]

Remove-WindowsFeature [servermanagercmd.exe –remove]

For more information: Microsoft Technet: Overview of Server Manager Commands

The classic Windows Powertoy “Open Command Prompt Here” is now part of Windows 7 Explorer. Hold down the shift key, then right-click a folder to add this option to the property menu.

image

While you're in a command prompt, if you want to open an Explorer window with the focus of the window on the current directory, enter start . 

image

There is an easy way to gain access to your administrative rights (read: admin token) with a keyboard shortcut. To provoke the UAC Consent or Credential Prompt - to elevate your selected application - press Ctrl+Shift+Enter.  This avoids the typical right-click “Run as Administrator” action.

image

There is also an easy way to gain access to your administrative rights (read: admin token) with a mouse shortcut.  To provoke the UAC Consent or Credential Prompt - to elevate your selected application – press Ctrl-Shift+left mouse click.  So, when you do Ctrl+Shift on a taskbar icon, or a start menu item, you've launched it with appropriate administrative rights using your admin token.

Windows Management Framework, which includes Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0, are officially released to the world. 

Windows Management Framework makes some updated management functionality in Windows 7 and in Windows Server 2008 R2 available to be installed on Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008. Windows Management Framework contains Windows Remote Management (WinRM) 2.0, Windows PowerShell 2.0 and Background Intelligent Transfer Service (BITS) 4.0.

IT Professionals can now easily manage their Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2 machines through PowerShell remoting. Again a huge step forward!

Windows PowerShell 2.0

Windows PowerShell is a command-line shell and scripting language that is designed for system administration and Automation. Built on the Microsoft .NET Framework, Windows PowerShell enables IT professionals and developers to control and automate the administration of Windows and applications.

New features that are introduced in Windows PowerShell 2.0 include the following:

  • Remoting
  • Integrated Scripting Environment (ISE)
  • Modules
  • Advanced functions
  • Background jobs
  • Eventing
  • Script internationalization
  • Script debugging
  • New cmdlets

WinRM 2.0

WinRM is the Microsoft implementation of WS-Management Protocol, a standard Simple Object Access Protocol (SOAP)–based, firewall-friendly protocol that allows for hardware and operating systems from different vendors to interoperate. The WS-Management Protocol specification provides a common way for systems to access and exchange management information across an IT infrastructure.

WinRM 2.0 includes the following new features:

  • The WinRM Client Shell API provides functionality to create and manage shells and shell operations, commands, and data streams on remote computers.
  • The WinRM Plug-in API provides functionality that enables a user to write plug-ins by implementing certain APIs for supported resources and operations.
  • WinRM 2.0 introduces a hosting framework. Two hosting models are supported. One is Internet Information Services (IIS)-based and the other is WinRM service-based.
  • Association traversal lets a user retrieve instances of Association classes by using a standard filtering mechanism.
  • WinRM 2.0 supports delegating user credentials across multiple remote computers.
  • Users of WinRM 2.0 can use Windows PowerShell cmdlets for system management.
  • WinRM has added a specific set of quotas that provide a better quality of service and allocate server resources to concurrent users. The WinRM quota set is based on the quota infrastructure that is implemented for the IIS service.

BITS 4.0

BITS is a service that transfers files between a client and a server. BITS provides a simple way to reliably and politely transfer files over HTTP or HTTPS. File downloads and file uploads are supported. By default, BITS transfers files in the background, unlike other protocols that transfer files in the foreground. Background transfers use only idle network bandwidth in order to preserve the user’s interactive experience with other network applications, such as Internet Explorer. Foreground or typical transfers are also supported.

BITS 4.0 includes the following new features:

  • Peer caching now uses Windows BranchCache. This new peer caching model replaces the model that is used for BITS 3.0.
  • A more flexible resource access model allows for applications to associate a pair of security tokens to a BITS transfer job.
  • The BITS Compact Server is a stand-alone HTTP/HTTPS file server that lets you transfer a limited number of large files asynchronously between computers.
  • More precise bandwidth throttling.

For more information: KB968929, KB968930

Download all components here

Download Windows Management Framework Core for Windows Server 2008 x86, Windows Server 2008 x64, Windows Server 2003 x86, Windows Server 2003 x64, Windows Vista x86, Windows Vista x64, Windows XP x86

image

“Covering every aspect of Windows Server 2008 R2 in nine chapters and approximately 200 pages is clearly an impossible task.
Rather than try to cover everything, we’ve focused on what is new and important, while giving you the context from Windows Server 2008.”

This free MS Press ebook covers Remote Desktop Services (RDS), VDI, Hyper-V 2.0, IIS 7.5, Branch Cache, Direct Access, Active Directory Domain Services (ADDS), DFS-R, Bitlocker-To-Go, etc…

Download here

A while ago, I wrote about the free P2V tool Disk2VHD from Sysinternals.  Now, an update is available that provides command line support.

Disk2vhd includes command-line options that enable you to script the creation of VHDs. Specify the volumes you want included in a snapshot by drive letter (e.g. c:) or use "*" to include all volumes.

Usage: disk2vhd <[drive: [drive:]...]|*> <vhdfile>
Example: disk2vhd * c:\vhd\snapshot.vhd

Download here

StarWind iSCSI SAN software is a storage virtualization software which turns any standard 64-bit or 32-bit Windows Server into a fail-safe SAN that uses an existing Ethernet network.  StarWind Enterprise HA is a special High Availability edition which uses Synchronous Data Mirroring with Active-Active Automated Failover and Failback technology, allowing the storage to continue operating properly in the event of a failure. This technology permits you to configure an Active-Active 2 Node storage cluster which ensures a highly reliable and fault tolerant storage.

So for building those Hyper-V clusters, Starwind certainly brings added value to the scene, by providing storage high-availability over iSCSI.

Enterprise-class features of StarWind HA include:

For more information:

Microsoft released an KB article Q957256 describing methods that you can use to (in-place) upgrade Hyper-V to Windows Server 2008 R2 from a Windows Server 2008 installation that has the Hyper-V role enabled.

During the in-place upgrade of the parent partition from Windows Server 2008 to Windows Server 2008 R2, the compatibility report will inform you that you must remove the Hyper-V role by using Server Manager before you continue with the upgrade. This is not necessary (as per KB957256).

Known incompatibilities

  • VM Saved State
  • VM Live/Online Snapshots (taken when VM was running, also using Saved State for memory content) – However, Offline snapshot are fully compatible (taken when VM was not running) with Hyper-V R2.
  • Upgrade VMs to latest Hyper-V R2 Integration Components once upgraded to Hyper-V R2. The synthetic devices (storage, networking, video and input devices) will continue to function until you upgrade the VM to the latest IC.  Improvements (such as: hot add/removal) made in the Hyper-V R2 Integration Components will not be available until the IC are updated.

For more detailed information: KB957256

Preparing for Upgrade

  • If the virtual machine is in a Running state, use Hyper-V Manager to shut down the virtual machine before upgrading.
  • If the virtual machine is in a Saved state, use Hyper-V Manager to start from the saved state and then shut down the virtual machine.
  • If the virtual machine has an online snapshot that you need, apply the relevant snapshot, and then shut down the virtual machines.
  • Ignoring above recommendations, results in issues with

    1. Saved states
    If you keep a VM in saved state through the upgrade/export to a Windows Server 2008 R2 host, the VM will be registered and will appear to be in the saved state. However, the VM will not be able to restore from the saved state. You will need to discard the saved state (Delete saved state) and then cold start the virtual machine.

    2. Online Snapshots
    You will be able to apply the snapshot and thus get the configuration and storage data associated with that snapshot. However, you will not be able to restore from the associated saved state. You will need to discard the saved state (Delete saved state) and restart the VM.

    Upgrading Hyper-V Clusters

    The KB article also deals with “Upgrade guidance for virtual machines on failover clusters”, which actually implies a rebuild of the cluster to Windows Server 2008 R2 with Hyper-V.

    For more detailed information: KB957256

    Migrating using VMM 2008 R2

    When moving/migrating VMs from a Hyper-V v1 host to a Hyper-V v2 (R2) host using VMM 2008 R2, all the above incompatibilities are taken into account and the new Windows Server 2008 R2 Integration Components/Services are installed seamlessly onto the newly migrated virtual machines as part of the migration process.

    More Posts Next page »