You are browsing the archive for Hyper-V.

PowerShell – BGInfo Automation script for Windows Server 2019

8:04 pm in BgInfo, Hyper-V, PowerShell, PowerShell Script, Sysinternals, VM Template, Windows Server 2019, WS2019 by Wim Matthyssen

Probably everyone knows the Sysinternals tool BGInfo (currently version 4.26). For those who don’t, it’s a great free tool from Microsoft which captures system information form a workstation or server (probably where it is the most useful) and displays that relevant data directly on the desktop of that particular machine. It can show useful information like, DNS settings, used IP Addresses, computer name, domain name, OS version, memory, service pack version, etc.

image

Whenever I create a new Windows Server 2019 Virtual Machine (VM) template for customers, I mostly add this tool in the base image (also called golden image) and set it so it starts up automatically whenever a user logs on to the server. To automate this process, I wrote a PowerShell script which automates the complete BGInfo installation and configuration.

This script will do all of the following:

  • Create the BGInfo folder on the C: drive if the folder does not already exist.
  • Download the latest BGInfo tool from the Sysinternals webpage.
  • Extract and cleanup the BGInfo.zip file in the BGInfo folder.
  • Download the logon.bgi file which holds the preferred settings.
  • Extract and cleanup the LogonBgi.zip file in the BGInfo folder.
  • Create the registry key (regkey) to AutoStart the BGInfo tool in combination with the logon.bgi config file.
  • Start BGInfo for the first time.
  • Exit the PowerShell window upon completion.

 

Prerequisites

  • Windows PowerShell 5.1
  • Run PowerShell as Administrator

 

PowerShell script

To use the script copy and save the above as BGInfo_Automated_Windows_Server_2019.ps1 or download it from the TechNet Gallery. Afterwards run the script with Administrator privileges from the server you wish to use for your VM template.

image

image

image

image

image

image

If you want to change any configuration setting (for example the font style or published info), just open the logon.bgi file and adjust the settings to your preferences. Click OK to save and set the new settings.

image

image

Hope this script comes in handy for you. If you have and questions or recommendations about it, feel free to contact me through my Twitter handle.

Wim Matthyssen (@wmatthyssen)

Hyper-V 2019: Configure antivirus exclusions in Windows Defender Antivirus

3:43 pm in antivirus exclusions, automatic exclusions, custom exclusions, Hyper-V, PowerShell, Windows Defender Antivirus, Windows Server, Windows Server 2019, Windows Server 2019 Hyper-V, WS2019 by Wim Matthyssen

Running a solid, constantly updated antivirus product on your Hyper-V hosts is a necessity to keep a healthy and secure virtual environment. By using Windows Defender Antivirus, the built-in antimalware solution in Windows Server 2019 you will be provided with next-gen cloud-delivered protection, which includes near-instant detection, always-on scanning and dedicated protection updates.

However, when using any antivirus software on a Hyper-V host, you also risk having issues when it is not configured properly and especially when real-time scanning (or monitoring) is enabled. This can negatively affect the overall host performance and even cause corruption of your virtual machines (VMs) or Hyper-V files.

To avoid these file conflicts and to minimize performance degradations you should implement the following recommend antivirus exclusions (directories, files and processes) on all your Hyper-V hosts, which can be found over here.

Luckily Windows Defender Antivirus automatically enrolls certain exclusions (automatic exclusions), defined by your specific server role. To determine which roles are installed on the server, Windows Defender Antivirus uses the Deployment Image Servicing and Management (DISM) tools. You should be aware that these automatic exclusions will not appear in the standard exclusion list shown in the Windows Security app.

clip_image002

Below you can find a list of the automatic exclusions for the Hyper-V role:

File type exclusions:

  • *.vhd,*.vhdx,*.avhd,*.avhdx,*.vsv,*.iso,*.rct,*.vmcx,*.vmrs

Folder exclusions:

  • %ProgramData%\Microsoft\Windows\Hyper-V
  • %ProgramFiles%\Hyper-V
  • %SystemDrive%\ProgramData\Microsoft\Windows\Hyper-V\Snapshots
  • %Public%\Documents\Hyper-V\Virtual Hard Disks

Process exclusions:

  • %systemroot%\System32\Vmms.exe
  • %systemroot%\System32\Vmwp.exe

Hyper-V Failover Cluster folder exclusions:

  • %SystemDrive%\ClusterStorage

Although the automatic exclusions include almost all recommended Hyper-V antivirus exclusions you still may need to configure additional custom exclusions. These custom exclusions will take precedence over the automatic exclusions but will not conflict if a duplicate exists.

If you prefer to disable automatic exclusions you can run the following PowerShell cmdlet.

Below you can find an additional short list of custom exclusions for a server running the Hyper-V role which you can implement if applicable to your environment. There can be even more exclusions for your specific environment.

  • Any custom virtual machine configuration or hard disk drive directories (for example E:\VMs).

clip_image004

  • Any custom replication data directories, if you’re using Hyper-V Replica.
  • The Vmsp.exe process (%systemroot%\System32\Vmsp.exe)

clip_image006

  • The Vmcompute.exe process (%systemroot%\System32\Vmcompute.exe).

clip_image008

To add these exclusions for Windows Defender Antivirus in the Windows Security app you can follow the below steps.

Open the Windows Security app by clicking the magnifier in the task bar and type defender. Select Virus & threat protection.

clip_image010

Under the Virus & threat protection settings title select Manage settings.

clip_image012

On the Virus & threat protection settings page scroll down to Exclusions setting and click on Add or remove exclusions.

clip_image014

Click Add an exclusion. Click the + icon to choose the type and set the options for each exclusion. When adding an exclusion click Yes if the User Account Control box pops up.

clip_image016

clip_image018

When all custom exclusions are added the screen will look like this.

clip_image020

To remove an added exclusion, press the down arrow next to the exclusion and click Remove.

clip_image022

You can also add these custom exclusions with the use of PowerShell (as administrator). To do so you need to run the below commands.

clip_image024

Hope this helps securing your Hyper-V hosts.

Wim Matthyssen (@wmatthyssen)

PowerShell: BgInfo Automation script for Windows Server 2012 R2

10:09 am in Bg, BgInfo, Hyper-V, PowerShell, PowerShell Script, scugbe, VM Template, Windows Server, Windows Server 2012 R2, Windows Sysinternals by Wim Matthyssen

Sometime ago I already wrote a PowerShell script to install the BgInfo tool in an automated way whenever you create a VM Template or a base image (also called golden image) for a Windows Server 2016 Virtual Machine (VM) or physical server, which can be donwloaded here. More information can be found int this previous blog post: http://scug.be/wim/2017/02/23/powershell-bginfo-automation-script/

To return to the current blog post and like you can already figure out from the title, now I also wrote a script to automate the BgInfo installation and configuration for a Windows Server 2012 R2 server (VM or physical server).

This PowerShell script will do all of the following:

  • Download the latest BgInfo tool
  • Create the BgInfo folder on the C drive
  • Extract and cleanup the BgInfo.zip file
  • Download the logon.bgi file which holds the preferred settings
  • Extract and cleanup the LogonBgi.zip file
  • Create the registry key (regkey) to AutoStart the BgInfo tool in combination with the logon.bgi config file
  • Start the tool for the first time
  • Set to start up automatically whenever a user logs on to the server

 

Prerequisites

Windows PowerShell 4.0

 

PowerShell script

To use the script copy and save the above as BgInfo_Automated_WS2012_R2_v1.0.ps1, or whatever name you prefer. Afterwards run the script with Administrator privileges from the server you wish to use for your VM template or physical base image. If you want to change configuration settings, just open the logon.bgi file and adjust the settings to your preferences.

This PowerShell script can also found on the TechNet Gallery: https://gallery.technet.microsoft.com/PowerShell-BgInfo-07ade714

image

image

image

image

image

Hope this script comes in handy for you. If you have and questions or recommendations, please feel free to contact me through my twitter handle.

Wim Matthyssen (@wmatthyssen)

Microsoft Wireless Display Adapter won’t connect with Windows 10 laptop running Hyper-V

8:35 pm in Client Hyper-V, Hyper-V, Microsoft Wireless Display Adapter, Miracast, Wi-Fi, Windows 10 by Wim Matthyssen

When delivering workshops at customers most of the time I use my Microsoft Wireless Display Adapter to show my presentations or demo’s on a big screen.

clip_image002

Normally, I only just need to plug in the USB and HDMI connectors from the Wireless Display Adapter to the HDTV, monitor or projector, and click Connect on the Windows 10 Action Center. My display adapter is then listed as on option and I only need to click on it to extend or duplicate my laptop screen. It is so easy and connecting with a Windows 10 device could not be quicker.

clip_image004

However last week while preparing a new Azure workshop, making a connection to my home TV did not go that smooth as usual. When I tried to connect to my display adapter, making a connection took a long time and at the end the message “Couldn’t connect” popped up while the TV was still showing Connecting.

 

clip_image006

clip_image008

After troubleshooting for some time and checking the usual steps (check adapter’s firmware, check Windows Updates, reset the adapter …) I finally figured it out. When making a connection the Wireless Display Adapter uses Miracast, a wireless technology, which makes communication between devices possible on either the 2.4 GHz or 5 GHz wireless frequency bands. The display adapter itself, even if it looks like a sort of HDMI to USB cable, has a full Wi-Fi card and antenna on board which it uses to connect to the wireless adapter on your laptop.

That is where my connection problem was situated. I do a lot of research on my laptop with the use of Client Hyper-V, which enables me to run all sorts of virtual machines (VMs) for testing purposes. For connecting some of those VMs to the Internet, I make use of an internal virtual switch, which uses a shared connection (Internet Connection Sharing) on my wireless adapter.

clip_image010

clip_image012

However, this Windows service causes some changes in the way the wireless adapter works, which in normal circumstances does not disturb anything, except when you try to connect to a Wireless Display Adapter.

So, after removing this sharing option, the Wireless Display Adapter connected as easily as before.

clip_image014

clip_image016

clip_image018

Conclusion

A Microsoft Wireless Display Adapter strongly depends on the wireless adapter in your device to setup communication. Any issues or changes to the wireless adapter in any way can cause connecting problems. If you still want to use Client Hyper-V on your Windows 10 laptop and connect your VM to the Internet with the use of your wireless adapter, I suggest to create an External virtual switch which connects to it. Do not forget to allow the management Operating System to share the wireless network adapter. This setup does not seem to disturb the connection with a Wireless Display Adapter.

Client Hyper-V: Unable to start a VM from saved state (Event ID 3326)

8:56 am in Client Hyper-V, Event ID 3326, Hyper-V, saved state, virtual machine by Wim Matthyssen

 

Last week while starting a virtual machine (VM) from saved state on my Windows 10 laptop with Client Hyper-V the following error popped up and the VM itself did not power on.

clip_image002

The error itself did not explain a lot why the startup from saved state was failing, but in the Hyper-V event logs (Event Viewer – Applications and Services Logs – Microsoft – Windows – Hyper-V-Worker – Admin) Event 3326 was shown which showed a lot more:

The Virtual Machine ‘VM-W8-HOME’ failed to start because there is not enough disk space. The system was unable to create the memory contents file on ‘C:\_VM\VM-W8-HOME\Virtual Machines\CB9D8995-F1FC-4349-9C35-7728F5B90245′ with the size of 7340 MB. Set the path to a disk with more storage space or delete unnecessary files from the disk and try again. (Virtual machine ID CB9D8995-F1FC-4349-9C35-7728F5B90245)

clip_image004

The error indicates that not enough free space is available on the host which causes problems to start the VM. The View in Disk Management (tap the Windows key + R to open Run, type diskmgmt.msc in the empty box and tap OK) indeed shows that the C: drive only has 2 % free, which is not sufficient to start the VM.

clip_image006

After determining that the error was caused by a lack of disk space, I cleaned up my C: drive by deleting some unnecessary and temporary files to free up some more space (at least 4096 MB which equals the amount of virtual memory of the VM). As a result, the VM started up again.

clip_image008

Conclusion

To start a VM from saved stated the amount of free disk space should at least equals the amount of virtual memory allocated to the VM. For example, if your VM has 4096 MB of virtual memory assigned, you should have at least 4096 MB available on the drive. If you do not have enough disk space available you should free up some space to be able to start the VM. As a recommendation you should always keep at least 10 – 20 % of free disk space available.

How to run the Hyper-V role on a VMware VM

10:16 am in Hyper-V, MABS v2, Nested Virtualization, PowerShell, VMware, Windows Server 2016 by Wim Matthyssen

When you install Microsoft Azure Backup Server (MABS) v2 on a Windows Server 2016, one of the prerequisites (MABS v2 prerequisites installation script) is that you install the Hyper-V role and the Hyper-V PowerShell feature.

However, while I was installing a new MABS v2 for a customer on a VMware VM (vSphere 6.5), I encountered following errors in the Hyper-V event log (41, 15350, 15340) after the Hyper-V role was installed.

Event 41 showed the following error message:

Hypervisor launch failed, Either VMX not present or not enabled in BIOS.

clip_image002

When I ran the Get-WindowsFeature in PowerShell it seemed Hyper-V was installed correctly. But this was not the case.

clip_image004

To fix the errors and get Hyper-V running like it should you need to enable Nested Virtualization for the VMware VM. To do so, shut down the VM and open the Virtual Machine Settings. Then go the Virtual Hardware tab and open the CPU options. There you need to check the box Expose hardware assisted virtualization to the guest OS. Also set CPU/MMU Virtualization to Hardware CPU and MMU.

clip_image006

When you now start the VM all Hyper-V related errors should be gone and all necessary Hyper-V services should be running.

clip_image008

clip_image010

Hope this blog post will help you whenever you need to setup Hyper-V on a VMware VM.

Wim Matthyssen (@wmatthyssen)

PowerShell: BgInfo Automation script

9:19 am in BgInfo, Client Hyper-V, Hyper-V, PowerShell, scvmm, VM Template, Windows Server 2016, Windows Sysinternals, WS2016 by Wim Matthyssen

Probably everyone knows the Windows Sysinternals tool BgInfo (currently version 4.21). For those who don’t, it’s a great free tool which captures system information from a workstation or server (probably where it is the most useful) and displays the catched data on the Desktop of that machine. It can show useful information like, DNS settings, used IP Addresses, computer name, domain name, OS version, memory, etc. If you want to read more about this tool you can do so via following link: https://technet.microsoft.com/en-us/sysinternals/bginfo.aspx

Whenever I create a new Windows Server 2016 Virtual Machine (VM) template for customers, I mostly add this tool in the base image (also called golden image) and set it so it starts up automatically whenever a user logs on to the server. To automate this process, I wrote a PowerShell script which does all of the following:

  • Download the latest BgInfo tool
  • Create the BgInfo folder on the C drive
  • Extract and cleanup the BgInfo.zip file
  • Download the logon.bgi file which holds the preferred settings
  • Extract and cleanup the LogonBgi.zip file
  • Create the registry key (regkey) to AutoStart the BgInfo tool in combination with the logon.bgi config file
  • Start the tool for the first time

Prerequisites

Windows PowerShell 5.0

PowerShell script:

To use the script copy and save the above as BGInfo_Automated_v1.0.ps1 or download it here. Afterwards run the script with Administrator privileges from the server you wish to use for your VM template. If you want to change configuration settings, just open the logon.bgi file and adjust the settings to your preferences.

image

image

image

image

Hope this script comes in handy for you. If you have and questions or recommendations about it, please contact me through my twitter handle.

Wim Matthyssen (@wmatthyssen)

2016: My blog year in an overview

2:37 pm in Azure, Azure Backup, Azure RemoteApp, Client Hyper-V, Cloud, DC, Hyper-V, IaaS, PowerShell, Private Cloud, Public Cloud, Replica DC, SCAC 2012 R2, SCVMM 2012 R2, System Center 2016, W2K12R2, Windows 10 by Wim Matthyssen

Hi all,

As a blogger completely focused on Microsoft technologies, it was a fun year of writing about all those interesting and ever changing products and services. As we almost end the year 2016 and are preparing for 2017 to start, I wanted to make a list of all the blog posts I wrote throughout the twelve months of 2016. During the year, I’ve published 26 blog posts mostly about Azure, the System Center Suite and Hyper-V. Below you can find them all divided by technology.

 

clip_image002

Azure Compute – IaaS (ASM)

Step-by-step: Move an Azure IaaS VM between different Azure Subscriptions

Clean up Azure PowerShell when using different Azure subscriptions

Replica DCs on Azure – Removing the Azure Endpoints

Replica DCs on Azure – Transferring FSMO roles to the IaaS DCs

Replica DCs on Azure – Manage the Time Configuration settings on the DCs

Replica DCs on Azure – Domain Controller Health Check

Replica DCs on Azure – Promote the Azure IaaS VMs to a domain controller

Replica DCs on Azure – Add the Active Directory Domain Services role

Replica DCs on Azure – Adjustment of some server settings before promoting the DCs

Replica DCs on Azure – Initialize and format the additional data disk

Replica DCs on Microsoft Azure – Create the VMs with Azure PowerShell

Step by step: Change the drive letter of the Temporary Storage on an Azure IaaS v1 VM

 

Azure Networking

How to connect an Azure ARM VNet to an ASM VNet using VNet Peering

Replica DCs on Azure – Switch DNS servers for the VNet

Replica DCs on Azure – Create the Active Directory site for the Azure VNet

 

Azure Backup

Microsoft Azure Backup Server: Install a new version of the Microsoft Azure Recovery Services Agent

Microsoft Azure Backup Server: System State backup fails with WSB Event ID: 546

Microsoft Azure Backup Server: System State backup fails with the message replica is inconsistent

Step by step: How to install Microsoft Azure Backup Server (MABS)

 

Azure RemoteApp

An RDP connection to the Azure RemoteApp custom VM fails with the following error: “No Remote Desktop License Servers available”

 

Windows 10

How to deploy Windows 10 from a USB flash drive

 

System Center

System Center 2016 evaluation VHDs download links

Step by step: How to connect SCAC 2012 R2 to SCVMM 2012 R2 and Microsoft Azure

Step by step: Installing SCAC 2012 R2

 

Hyper-V

A list of tools that can be used to do a V2V from VMware to Hyper-V

Client Hyper-V – Using nested virtualization to run Client Hyper-V on a Windows 10 VM

 

Before I wrap up this blog post, I want to thank you all for reading my blog posts in 2016, and I really hope you will keep doing so in 2017. I wish you all a healthy, successful and outstanding New Year! See you all in 2017!

Wim Matthyssen (@wmatthyssen)

System Center 2016 evaluation VHDs download links

4:04 pm in Hyper-V, SCDPM, SCOM, SCORCH, SCSM, scvmm, System Center 2016, VHD by Wim Matthyssen

 

Hi all,

Just a short blog post today. Like you probably already know System Center 2016 is officially launched on the 26th of September during Microsoft Ignite.

 

clip_image002

For all you guys running Hyper-V 2012 R2, and I hope that are a lot of you, Microsoft recently also released the System Center Evaluation VHDs (RTM version). The different download links, which you can find below, each consists of files that you extract into a single pre-configured VHD file. There are VHDs for several different System Center components like SCVMM, SCOM and SCDPM, but also for SCSM and SCORCH. When each VHD is downloaded it will enable you to create a VM (Generation 1) which you can use to evaluate and test each different System Center component. Be aware that most of these VMs ran in a Workgroup. It’s best to already have a DC configured and setup in your test environment, so you can join them into your test domain before you start playing around with them.

Hereby the list for are all the System Center 2016 Evaluation VHDs available for download:

Hope this helps you getting familiar with these new releases.

Wim Matthyssen (@wmatthyssen)

A list of tools that can be used to do a V2V from VMware to Hyper-V

11:49 am in Hyper-V, MVMC, SCVMM 2012 R2, V2V, VMware by Wim Matthyssen

From time to time clients ask me to convert VMware virtual machines (VM) to Hyper-V VMs. Briefly said to do a virtual-to-virtual (V2V) migration.

clip_image002

Most of the times those clients have System Center Virtual Machine Manager 2012 R2 (SCVMM) in place, which can perform those migrations with ease. You can find how you can do this by using SCVMM via following Microsoft TechNet article: https://technet.microsoft.com/en-us/library/gg610672(v=sc.12).aspx

But there are also clients who don’t make use of the System Center Suite, mostly because of the price or because they have a small environment. Therefore, other tools need to be used for these V2V migrations. In this blog post I will list up some of those tools (Microsoft and third party), all with their pros and cons.

Before I start listing them up, I would like to draw your attention to some things you should keep in mind:

  • Always check the current VMware ESX version -> not all tools migrate all versions of ESX
  • Check the guest OS version -> not all tools migrate all versions of the guest OS installed
  • Be aware that almost every migration process will introduce downtime -> no “warm migration”, VMware VM down, Hyper-V VM up
  • Hyper-V GEN 1 VMs -> Only an IDE disk can be used to boot a VM, no SCSI boot from VHD
  • Hyper-V GEN 1 VMs -> Never configure a paging file on a VHD connected to a SCSI Controller
  • Hyper-V GEN 2 VMs -> Only supports the following Windows guest operating systems (OSs): Windows Server 2012 R2, Windows Server 2012, 64-bit versions of Windows 8.1 and 64-bit versions of Windows 8

Below you can find the list of the different V2V migration tools:

1) Microsoft Virtual Machine Converter (MVMC) 3.0

Download link: https://www.microsoft.com/en-us/download/details.aspx?id=42497

Microsoft TechNet article: https://technet.microsoft.com/en-us/library/dn873998(v=ws.11).aspx

Pros:

  • Free
  • Automation via PowerShell
  • Can integrate with System Center Orchestrator (SCORCH) 2012 R2
  • VM and physical server (online) conversion
  • Not only Hyper-V but also Microsoft Azure is available as migration destination
  • Uninstalls VMware tools before an online conversion (VMware tools will not be uninstalled when an offline conversion is used)

Cons:

  • No GEN 2 VM support

2) 5nine V2V Easy Converter 6.5 free version

Download link: http://www.5nine.com/vmware-hyper-v-v2v-conversion-free.aspx

Pros:

  • Free
  • GEN 2 VM support
  • Ability to override the number of vCPUs and the available vMemory
  • Remap the vNetwork
  • Ability to override the VM start/stop/delay actions
  • Automatic conversion into a Highly Available Hyper-V VM is available
  • Faster than MVMC

Cons:

  • No automation trough PowerShell for the migration process in the free edition (only in the payed edition)
  • Does not remove VMware tools automatically

3) StarWind V2V Converter

Download link: https://www.starwindsoftware.com/converter

Pros:

  • Free
  • Converts VMs from any format (VMDK, VHD, VHDX, …) to another

Cons:

  • Requires registration in order to download it
  • Does not remove VMware tools automatically

Before ending this post, I also want to mention the Disk2vhd tool which enables you to do a physical-to-virtual (P2V) migration. You can dowload it via following link: https://technet.microsoft.com/en-us/sysinternals/ee656415.aspx

You can also read all about how to use this tool in a blog post I wrote some time ago: http://scug.be/wim/2015/01/22/how-to-perform-a-p2v-with-disk2vhd/

Like you can see you have several tools you can use, all with their advantages and possible disadvantages. Newer versions of those tools mostly include new features and add support for more OSs. I mostly prefer to use MVMC if SCVMM is not available to do the migration, but off course the choice is all yours. Hopefully this list helps, till next time!

Wim Matthyssen (@wmatthyssen)