Introduction
Today I will tell you how to install and configure the hypervisor from Microsoft, as well as how to manage it.
So, first a small lyrical digression.
As the existing infrastructure has been optimized, the question of virtualization has come up. I immediately remembered a wonderful solution from VMware - ESXi, with which I had repeatedly worked and was more than pleased and was about to migrate to it, but fate decreed otherwise. In the process of planning and choosing a virtualization platform, Hyper-V unexpectedly defeated.
Two things tipped the scales in his direction: excellent iron support, as well as the fact that my organization uses only Microsoft products, as a result of which we have closer integration and better manageability. Unfortunately, AD support was announced in ESXi 4.1 after the beginning of the migration, otherwise I would probably think about it.
As many know, Hyper-V Server 2008 R2 is a free product and is a Windows Server 2008 R2 Standard operating system running in Server Core mode (that is, without a GUI) and with the Hyper-V role enabled. In this regard, there are some difficulties in setting up the system for the “Windows” admins, since there are no magic buttons “next” and “ready”, and for Linux users and even less - the syntax of the commands in Windows does not lie next to Nix. .
Installation
Let's start with the installation.
Installing from a CD is not a big deal - they booted from the disc, chose a language, agreed to the license agreement, chose a section and “left to smoke” for 10 minutes.

Customization
Now the fun begins - tuning.
When you first log into the system, we see a text menu that allows you to perform the initial configuration of the server.

In my opinion, it is not very convenient, besides, by default you will not be able to remotely connect to the server using the Hyper-V Manager, so safely close it and go to the command line.
1. Set admin passwordrun
net user administrator *
and enter a new password
2. Network SetupBy default, network adapters are configured to receive an address via DHCP, if that suits you, you can go directly to step 3.
Run the
netsh interface ipv4 show interface
command, remember the IDx of the desired network card.
Run the
netsh interface ipv4 set address name='2' source=static address=192.168.0.2 mask=255.255.255.0 gateway=192.168.0.1
command
netsh interface ipv4 set address name='2' source=static address=192.168.0.2 mask=255.255.255.0 gateway=192.168.0.1
where 2 is the same IDx.
To configure the servers dns, run
netsh interface ipv4 add dnsserver name='2' address=192.168.0.10
You can always return your native settings with the
netsh interface ipv4 set address name='2' source=dhcp
command
netsh interface ipv4 set address name='2' source=dhcp
3. Computer name and domain entryIn principle, the domain is not necessarily needed, but it greatly simplifies life, later I will tell why. We will assume that there is a domain and we will use this achievement of human thought.
Look at the computer name with the
hostname
command
Change the computer name with the
netdom renamecomputer WIN-KMTUYKKZPJQ /newname:vm1
, where WIN-KMTUYKKZPJQ is the old name of your computer, and vm1 is the new one.
Enter the computer into the domain
netdom join vm1 /domain:contoso.com /userd:administrator /password:*
command and enter the password for the specified account.
Reboot.
This completes the initial setup.
')
Control
To manage the server, you need to download and install Remote Server Administration Tools (RSAT) for the client operating system and install the Hyper-V Manager component, or add the Hyper-V role and install the Hyper-V Manager component on Windows Server 2008 R2.
We are trying to connect to our server and see an error that tells us to bring the admin to the beer so that it gives the necessary rights. Remembering that we are the same admin, do not lose heart and read on.
John Howard, who holds the post of Senior Program Manager in the Hyper-V team at Microsoft, wrote a series of articles devoted to the distribution of the necessary rights, and subsequently concocted a wonderful utility
HVRemote , which will produce a clever setup of the server and client, without exploding the brain of the admin.
We will take advantage of it. So,
download , go to the server at
\\ server \ C $ , put HVremote.wsf in the Windows folder (or in any other place, but then do not forget to specify the full path to it). Run on the server:
cscript hvremote.wsf /add:domain\account ***
, where domain \ account is your username in the domain. The script will prescribe all the necessary privileges, including open the necessary ports on the firewall.
Then, on the cscript hvremote.wsf / mmc: enable client, the script will create exceptions for the firewall.
Now you can run Hyper-V Manager and connect to our server, create virtuals and enjoy life.

Conclusion
I'll tell you about some points that I had to face:
1. Use the English version of Hyper-V - the script on the Russian language will not work, since the names of the groups in the firewall will be different. From the client, the hyper-v interface will still be Russian.
2. Use a domain. If there is no domain, you will need to follow these steps:
• Create an account on the server and client using
net user
• Give this user
cscript hvremote.wsf /add:accountname ***
access
cscript hvremote.wsf /add:accountname ***
• On the client, allow anonymous access to DCOM
cscript hvremote.wsf /anondcom:grant
, log in using the same account that was allowed access on the server, or launch Hyper-V Manager from under the required account, set credentials for connecting to the server
cmdkey /add:servername /user:servername\account /pass
command
cmdkey /add:servername /user:servername\account /pass
, as well as create firewall exceptions with the
cscript hvremote.wsf /mmc:enable
command
That's all. If you have questions - I will answer with pleasure.
PS: The author is my friend CLaiN.