Jun 122016
 

2012 Server sysprep fails during MDT capture sequence

I recently experienced an issue while updating my 2012 server image on my MDT deployment share.  The newly updated 2012 Server sysprep fails during the sysprep capture process.  The MDT task sequence indicated the following sysprep error:

IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE actual image state is IMAGE_STATE_UNDEPLOYABLE

A review of the sysprep error log (C:\Windows\System32\sysprep\setuperr.log) revealed the following issue:

2016-06-12 11:18:21, Error      [0x0f00bf] SYSPRP CreateSysprepActionList: Invalid action node sysprepOrder found for component Microsoft-Windows-SoftwareInventoryLogging-ScheduledTasks
2016-06-12 11:18:21, Error                 SYSPRP SysprepSession::Execute: Error in executing actions from C:\Windows\System32\Sysprep\ActionFiles\Generalize.xml; dwRet = 0x10dd
2016-06-12 11:18:21, Error                 SYSPRP RunPlatformActions:Failed while executing SysprepSession actions; dwRet = 0x10dd
2016-06-12 11:18:21, Error      [0x0f0070] SYSPRP RunExternalDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x10dd
2016-06-12 11:18:21, Error      [0x0f00a8] SYSPRP WinMain:Hit failure while processing sysprep generalize internal providers; hr = 0x800710dd


It took two days of research to track this one down and it ended up being related to the Windows Management Framework (WMF) 5.0 RTM which I was including in my image refresh.
Apparently there is a known Bug: WMF 5 Production Preview on Windows Server 2012 breaks Sysprep

In the following article: WMF 5.0 Known Issues and Limitations I discovered a workaround for this problem which I have included below.  It essentially involves modifying the Generalize.xml for sysprep to accommodate the upgrade to WMF 5.0.  I made the necessary changes and sysprep and the MDT capture sequence worked without issue.

For systems running Windows Server 2012

  1. After installing WMF 5.0 on the server to be Sysprep’d, login as administrator.
  2. Copy Generize.xml from directory \Windows\System32\Sysprep\ActionFiles\ to a location outside of the Windows directory, C:\ for example.
  3. Open your Generalize.xml copy with notepad.
  4. Find and remove the following text, one instance of each needs to be deleted (they will be near the end of the document).
    • <sysprepOrder order=”0x3200″></sysprepOrder>
    • <sysprepOrder order=”0x3300″></sysprepOrder>
  5. Save the edited copy of Generalize.xml and close the file.
  6. Open a command prompt as administrator
  7. Run the following command to take ownership of the Generalize.xml file in system32 folder: Takeown /f C:\Windows\System32\Sysprep\ActionFiles\Generalize.xml
  8. Run the following command to set appropriate permission on the file: Cacls C:\Windows\System32\ Sysprep\ActionFiles\Generalize.xml /G `<Administrator>`:F
    • Answer Yes at the prompt for confirmation.
    • Note that <AdministratorUserName> should be replaced by the username who is administrator on the machine. For example, “Administrator”.
  9. Copy the file you edited and saved over to the Sysprep directory using the following command: xcopy C:\Generalize.xml C:\Windows\System32\Sysprep\ActionFiles\Generalize.xml
    • Answer Yes to overwrite (note that if there is no prompt to overwrite, double check the path entered).
    • Assumes your edited copy of Generalize.xml was copied to C:\ .
  10. Generalize.xml is now updated with the workaround. Please run Sysprep with the generalize option enabled.

 

Jun 052016
 

2012R2 Hyper-V Hotfixes Info

The bulk of my work these days involves engineering and architecture around the 2012R2 Hyper-V platform.  We support hundreds of Hypervisors so I have seen my fair share of Hyper-V issues.  I’ve worked with Microsoft through many Hyper-V Sev-A / Sev-B cases, and even had Microsoft on site to troubleshoot several complex issues.  Through all that I have compiled a list of 26 2012R2 Hyper-V hotfixes that I am presently proactively applying to all new Hyps and retroactively applying to existing ones.  If you’re like me then throughout your Windows career you’ve only applied hotfixes when a problem presented itself that a hotfix specifically addressed.  For me, this is the exception.  I’ve seen this set of hotfixes solve a myriad of Hyper-V issues and prevent those issues from occurring on newly deployed Hyps.

Below you will find:

  • Links to Microsoft articles which outline all available 2012R2 Hyper-V hotfixes
  • My recommended list of mandatory 2012R2 Hyper-V hotfixes with links to each hotfix
  • I have pre-packaged my custom hotfix set into a .zip for your download convenience – you may alternatively visit the links below and download each hotfix individually
  • Powershell script to test for and automatically install the set of 2012R2 Hyper-V hotfixes

As with all things patching and hotfix related you are hereby cautioned to research each hotfix, it’s prerequisites, purpose, and potential impact on your environment.  Test this in your lab before rolling to production, then test some more.  It’s a good idea to be at the latest windows patch level on the Hyp prior to installing the hotfixes.  In my experience I have utilized the script below to apply the complete set to hundreds of Hyps with zero issues.  If a hotfix doesn’t apply (many won’t – for example – standalone [non-clustered] Hyps) the script simply carries on to the next hotfix.  Only those that are applicable to your Hyp will be applied.  Test!  I hope these improve your environment as much as they have mine.

2012R2 Hyper-V Hotfix Links

All relevant links for Hyper-V hotfixes are listed below in order of importance.  You can find title, purpose, and download links referenced in these articles.  If you support a Hyper-V environment I recommend you become very familiar with these articles and check back from time to time as they are updated.

My recommended 26 2012R2 Hyper-V Hotfixes

KB3093899= VMs that run on CSVs fail if DCM can't query volumes in Windows Server 2012 R2
KB3091057 = Cluster validation fails in the Validate Simultaneous Failover test in a Windows Server 2012 R2-based failover cluster
KB3076953 = Cluster services go offline when there's a connectivity issue in Windows Server 2012 R2 or Windows Server 2012
KB3068445 = Virtual machines that host on Windows Server 2012 R2 may crash or restart unexpectedly
KB3068444 = An unrecoverable failure occurred inside the filter manager error on a failover cluster node that hosts shared VHDx files
KB3090343 = Cluster service stops during the VSS backup in a Windows Server 2012 R2-based Hyper-V cluster
KB3060678 = Snapshots are not deleted after you perform a backup operation by using VSS in Windows Server
KB3063283 = Update to improve the backup of Hyper-V Integrated components in Hyper-V Server 2012 R2
KB3130944 = March 2016 update for Windows Server 2012 R2 clusters to fix several issues
KB3139896 = Hyper-V guest may freeze when it is running failover cluster service together with shared VHDX in Windows Server 2012 R2
KB3130939 = Nonpaged pool memory leak occurs in a Windows Server 2012 R2-based failover cluster
KB3141074 = 0x00000001 Stop error when a shared VHDX file is accessed in Windows Server 2012 R2-based Hyper-V guest
KB3072380 = Hyper-V cluster unnecessarily recovers the virtual machine resources in Windows Server 2012 R2
KB3031598 = Hyper-V host crashes and has errors when you perform a VM live migration in Windows 8.1 and Windows Server 2012 R2
KB3095308 = VMs may not get additional memory although they're set to use Dynamic Memory in Windows Server 2012 R2
KB3027108 = 0x0000003B or 0x0000007E Stop error on a Windows-based computer that has 4K sector disks
KB3037313 = Old files are not removed after a migration of virtual machine storage in Windows 8.1 or Windows Server 2012 R2
KB3025091 = Shared Hyper-V virtual disk is inaccessible when it's located in Storage Spaces on a Windows Server 2012 R2-based computer
KB3018489 = No host bus adapter is present error when querying SAS cable issues in Windows Server 2012 R2 or Windows Server 2012
KB3046826 = You cannot upgrade Hyper-V integration components or back up Windows virtual machines
KB3020717 = VMMS crashes when you perform live migration and request VM information at the same time in Windows Server 2012 R2
KB3044457 = STATUS_PURGE_FAILED error when you perform VM replications by using SCVMM in Windows Server 2012 R2
KB3036173 = 0x00000050 Stop error when Hyper-V host crashes in Windows Server 2012 R2
KB3049443 = Live migration of virtual machine to another host fails on a Windows Server 2012 R2-based Hyper-V host server
KB3102354 = Hyper-V generation 2 virtual machines can't start with some pass-through disks in Windows Server 2012 R2
KB3137691 = LBFO Dynamic Teaming mode may drop packets in Windows Server 2012 R2


2012R2 Hyper-V Hotfixes .zip download

The linked zip file below contains the 26 hotifxes identified above.  If you utilize this zip then the script below will be able to automatically apply all required hotfixes to your Hyper-V server.

2012R2 Hyper-V Hotfixes ZIP download

Powershell Test-Hotfixes / Install-Hotfixes

In the GitHub link below you will find hotfixes.ps1 which will test to see if the 26 hotfixes are applied on your Hyper-V server.  Keep in mind that not all hotfixes are applicable to all configurations, and that some of the hotfixes are available via Windows Updates.  Install-Hotfixes will attempt to install each hotfix on your Hyper-V server.  Any hotfix that is not applicable is ignored and the script will move on to the next hotfix.

It is unlikely that all 26 will be required on your server so if Test-Hotfixes still shows a few missing after you attempt install, this is perfectly fine.

https://github.com/techthoughts2/2012R2HyperVHotfixes

 

Feb 282016
 

What is the PowerShell Gallery?

Microsoft states:

The PowerShell Gallery is the central repository for PowerShell content. You can find new PowerShell commands or Desired State Configuration (DSC) resources in the Gallery.

Wait a second, doesn’t that sound a lot like the Microsoft Script Center?  Yes, it does.  The two both serve as a searchable repository for scripts and modules around the PowerShell scripting language.  The PowerShell Gallery offers up some distinctly different capabilities however.  For one, all scripts and modules are interacted with through, you guessed it, the PowerShell console.  While you can search the web-based gallery all other actions: downloading, installing, and publishing of PowerShell scripts and modules are handled from within PowerShell.  The Microsoft Script Center’s web-centric platform remains an excellent resource for System Administrator Scripters and other IT professionals.  The PowerShell gallery just has a much more devops(y) feel and, to date, has a repository base that more reflects that line of work.

There’s likely to be some cross-over between the two as the PowerShell Gallery matures and the Script Center will likely be with us for some time.  The PowerShell Gallery’s ability to rapidly search for, install, and easily update (something Script Center wasn’t great at) scripts and modules will likely make it the repository of choice moving forward though.

PowerShell Gallery Setup 101

All that’s required is the PowerShellGet module and NuGet provider (package manger)

Continue reading »

Feb 102016
 

What is a Hyper-V VM BIN file?

The .bin file is a Hyper-V VM associated file located inside the GUID folder of a VM.

If a VM’s AutomaticStopAction is set to: Save the virtual machine state then Hyper-V will reserve disk space equal to the amount of memory used by the virtual machine when it is running so that memory can be written to disk when the physical computer shuts down. If the VM is powered off, there will be no BIN file present, even if the VM is set to save.

Hyper-V Automatic Stop Action Settings

Hyper-V Automatic Stop Action Settings

How does the AutomaticStopAction setting affect available disk space?

The file acts as reserve point on the disk for the memory of a VM and can be located inside the GUID folder mentioned above.

The example below shows the VMs GUID location for a VM that was created with 8GB of RAM.  Because the VM’s AutomaticStopAction is set to save the virtual machine state approximately 8GB of hard drive space is reserved.

Hyper-V .bin file for a VM with 8GB of RAM

Hyper-V .bin file

Continue reading »

Dec 062015
 

Introducing Diag-V, a Powershell Hyper-V Diagnostic Utility

Diag-V is a PowerShell based script that contains a collection of various Hyper-V diagnostics. It presents the user a simple choice menu that allows the user to select and execute the desired diagnostic.

Where can I download Diag-V?

Download Diag-V from Technet via the link below:

https://gallery.technet.microsoft.com/scriptcenter/Diag-V-A-Hyper-V-0fe983e4

I want to contribute to Diag-V

Great! If you find a bug or think a diagnostic should be added you can see the code and contribute via Git at the link below:

https://github.com/techthoughts2/Diag-V

How do I use Diag-V?

Take a look at this short video demo or visit the technet/git links above for a detailed how-to breakdown.

Diag-V - A Hyper-V Diagnostic - Main Menu

Diag-V Main Menu

What diagnostics can Diag-V perform?

Continue reading »

Dec 042015
 

Using PowerShell to perform a Hyper-V resource allocation check

This Powershell script determines the current resource allocation health of a Hyper-V server or nodes in a Hyper-V Cluster.  The script will automatically scan the physical resources of each Hyper-V node and then compare that to the resources allocated to the Virtual Machines.  It will then pass/fail based on the following criteria:

1:1 Memory – anything higher fails

*This is for static memory only, see below for best practice suggestions regarding dynamic memory

4:1 CPU – anything higher fails

20% free storage space – anything lower fails

These ratios can be edited in the script to suit your desired cutoff points.

Here is a brief video that shows how to run and interpret the script:

The following is an example of the scripts output from a two-node Hyper-V Cluster.

Hyper-V Resource Allocation Check - Test-HyperVAllocation - Overprovisioning diagnostic for Hyper-V

Hyper-V Resource Allocation Check – Test-HyperVAllocation

Download / Review Hyper-V resource allocation check

Download the script from the TechNet Script Center here:

Hyper-V resource allocation check to determine if resources are overprovisioned

Continue reading »

Sep 192015
 

PowerShell Automation Script: Transfer all FSMO roles from one DC to another DC

If you prefer video over written format the corresponding video for this write-up can be viewed below:

I came across an excellent write-up the other day on vGeek:

Powershell – Domain Controller inventory and Transfering / moving FSMO roles between DC

This article highlighted two PowerShell commands that can be leveraged to Transfer all FSMO roles from one DC to another:

Get-ADDomainController

Move-ADDirectoryServerOperationMasterRole

Get-ADDomainController can be utilized to retrieve a list of present FSMO roles on a DC via the OperationMasterRoles Property:

Get-ADDomainController -Server dcName | `
    Select-Object -ExpandProperty OperationMasterRoles

Move-ADDirectoryServerOperationMasterRole can then be utilized to actually move the operations master roles to another Active Directory directory server (by name or by corresponding number):

 
Move-ADDirectoryServerOperationMasterRole -Identity ` 
    dcNameMovingTo –OperationMasterRole 0,1,2,3,4 ` 
    -Confirm:$false 

I wanted to take these two PowerShell commands further and automate the process of detecting present FSMO roles and automatically move them without having to manually specify each operations master role by name or number.

My goal for this PowerShell script was to detect existing FSMO roles on the DC you are running on, present a list of available DCs in the domain, and then let you move the FSMO roles to the DC you specify.

Continue reading »

Sep 152015
 

How To: Create New-VHD via PowerShell or GUI and attach to existing VM

If you prefer video over written format the corresponding video for this write-up can be viewed below:

Here is all the PowerShell code required for the creation of a new VHD.  The code below can be used to prompt for all needed settings to fully setup and configure a new .vhd/.vhdx and will attach it to the VM you specify.  This is a fully functional script that could be easily modified to automate a wide range of tasks involving the creation of additional .vhd(s)/.vhdx(s).  A full write-up with examples for the GUI can also be found below.

Continue reading »

Sep 132015
 

If you prefer video over written format the corresponding video for this write-up can be viewed below:

Here is all the PowerShell code required for the creation of a new Hyper-V VM.  The code below can be used to prompt for all needed settings to fully setup and configure a new Hyper-V VM.  This is a fully functional script that could be easily modified to spin up multiple VMs at once, or even import settings from a .csv or .txt file.  A full write-up with examples for the GUI can also be found below.

Continue reading »

Sep 122015
 

Migration of physical server to Hyper-V VM – P2V using Disk2vhd

If you prefer video over written format the corresponding video for this write-up can be viewed below:

P2V (or Physical to Virtual) is a process wherein you can take an existing physical server and convert it to a format that can then be run on a virtualized platform, such as Hyper-V.  There are a variety of methods and tools that can be used to accomplish this and this article will focus on one of those: P2V using Disk2vhd

P2V using Disk2vhd

Disk2vhd is a Sysinternals tool By Mark Russinovich.  It is an extremely easy to use utility that creates VHD (Virtual Hard Disk – Microsoft’s Virtual Machine disk format) by leveraging Windows’ Volume Snapshot capability to create consistent point-in-time snapshots of the volumes you want to include in a conversion.

This can be performed while the physical server is online and running so this method of conversion can be accomplished with relatively little or even no downtime.

High Level Overview of P2V using Disk2vhd

  1. Download the Disk2vhd utility
  2. Run Disk2vhd on the physical server you wish to convert to a Hyper-V VM
  3. Create a new VM on the Hyper-V hyp and attach the .vhd(s)/.vhdx(s) created by the Disk2vhd utility
  4. Start the new VM (with no vSwitch) and verify everything is operating as expected
  5. Remove any unwanted devices from device manager that are remnants from the physical device.
  6. Shut down physical server
  7. Associate VM NIC with appropriate vSwitch and configure IP information

Step by step of P2V using Disk2vhd

Continue reading »