Managing Hyper-V with PowerShell

Source: Internet
Author: User

Managing Hyper-V with PowerShell

Windows Server-Hyper-V is powerful, not only with GUI graphical interface management, but also with Windows PowerShell, Windows Server 2012 R2 all of the features can use PowerShell, so it's important to Hypervisio,powershell both the Windows Server R2 GUI and the Server Core, or the Microsoft Standalone Server virtualization product. However, most people like to use the graphical interface to do the operation, in fact, when you go deep into the PowerShell, you will realize that Hyper-V has a lot of features are not available GUI graphical interface, but in the PowerShell environment can be used normally. So in the last issue of the blog for you to introduce the basic management of the GUI after today to introduce the use of PowerShell.

Windows PowerShell is a scripted solution for automating tasks in Windows Server. Windows PowerShell new Hyper-V cmdlets are designed specifically for IT pros that allow them to perform tasks that can be performed in the graphical user interface of Hyper-V Manager, and there are some tasks that are only available through Windows PowerShell CMDlet to perform the

One, in Windows PowerShell, use the Get-command command to display all Hyper-V-related commands:

650) this.width=650; "height=" 313 "title=" clip_image002 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image002 " Src= "http://s3.51cto.com/wyfs02/M00/77/01/wKiom1Zg4cXx0sGoAADAf57JvOg854.jpg" border= "0"/>

In addition to using Windows PowerShell, we can manage Hyper-V using PowerShell 3.0. PowerShell Ise is a PowerShell integrated development environment integrated in Windows Server, in Windows Server 8/10, enter PowerShell ise in the Run window to open PowerShell Ise

650) this.width=650; "height=" 341 "title=" clip_image004 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image004 " Src= "http://s3.51cto.com/wyfs02/M01/77/00/wKioL1Zg4jGTx8d2AACdpM5cLrE021.jpg" border= "0"/>

Ii. simple configuration of Hyper-V using PowerShell

1. Remote management of Hyper-V via PowerShell Ise

As we have already said, to manage Hyper-V hosts, but do not want to go to the computer room, then you can use the Hyper-V Manager for graphical remote operations management of Hyper-V server, also we can be using PowerShell ISE remote management Hyper-V server, however, To manage Hyper-V Server 2012 and later, you must be managed by using Windows 8/10 or PowerShell ise in Windows Server 2012, not with the lower version of PowerShell Ise.

First select the new Remote PowerShell tab in the file. then click Connect.

650) this.width=650; "height=" 290 "title=" clip_image005 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image005 " Src= "Http://s3.51cto.com/wyfs02/M01/77/00/wKioL1Zg4jOBsVhzAAE1ttc6v6I560.png" border= "0"/>

Enter your password and click OK:

650) this.width=650; "height=" 484 "title=" clip_image006 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image006 " Src= "Http://s3.51cto.com/wyfs02/M00/77/01/wKiom1Zg4cuTY4mlAAFnmkFkwlU526.png" border= "0"/>

OK, it has been successfully connected to Hv-03:

650) this.width=650; "height=" 181 "title=" clip_image008 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image008 " Src= "http://s3.51cto.com/wyfs02/M02/77/00/wKioL1Zg4jagyQ1hAABtVIqbNVg943.jpg" border= "0"/>

2 , set the Hyper-V virtual hard disk storage location

We know that Windows, by default, installs everything in a partition, that is, where the OS is installed, where other configurations are installed, in order to be afraid of errors when the novice is configured, but there is a problem with all the configuration and OS hybrid installation, greatly affecting the performance of the system, So the first step in planning a virtual server is to configure the service to store the path. Windows Server R2 The default Hyper-V virtual hard disk storage path is: C:\Users\Public\Documents\Hyper-V\Virtual HDD Disks; But in this experiment, my disk is also divided into a zone, So I'm going to use PowerShell to modify the Hyper-V virtual hard disk storage location setting to C:\Hyper-V\ Disks, which is automatically created if this folder is not available. , the steps are as follows:

PowerShell modify command for Set-vmhost-virtualharddiskpath "C:\Hyper-V\ Disks"

650) this.width=650; "height=" "title=" clip_image010 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image010 " Src= "http://s3.51cto.com/wyfs02/M00/77/00/wKioL1Zg4jfigIi_AAA3dDd6L2I595.jpg" border= "0"/>

3. Modify the storage location of the virtual machine:

Without specifying where the virtual machine is stored, the default storage path for Windows Server R2 default virtual machine is: C:\ProgramData\Microsoft\Windows\Hyper-V Using PowerShell, you can modify the storage location of Hyper-V virtual machines, such as the ability to store virtual machines in C:\Hyper-v\VMM, which is created by default without this folder. The specific commands are as follows:

Set-vmhost-virtualmachinepath "C:\Hyper-v\VMM"

650) this.width=650; "height=" "title=" clip_image012 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image012 " Src= "http://s3.51cto.com/wyfs02/M00/77/01/wKiom1Zg4c6TBbsmAAAmwQmEeD4968.jpg" border= "0"/>

4. Numa spanning settings:

Non-Uniform Memory access (NUMA) is a computer memory design for multi-processor, and memory access time depends on the memory location of the processor. Under NUMA, the processor accesses its own local memory faster than the non-local memory (the processor or memory shared between the memory and the other processor). If you need to turn on the NUMA spanning feature of the server, in the Hyper-V host setting "Numa spanning" option, you can tick "allow virtual machines to cross physical NUMA nodes" as shown in:

650) this.width=650; "height=" 181 "title=" clip_image014 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image014 " Src= "http://s3.51cto.com/wyfs02/M01/77/00/wKioL1Zg4jmhikG7AACa7NDuE7k206.jpg" border= "0"/>

PowerShell command to allow virtual machines to span physical NUMA nodes: "Set-vmhost-numaspanningenabled $true"

650) this.width=650; "height=" "title=" clip_image016 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image016 " Src= "http://s3.51cto.com/wyfs02/M01/77/00/wKioL1Zg4jqzEZr0AAAtYH3SlDg311.jpg" border= "0"/>

PowerShell command to allow virtual machines to span physical NUMA nodes: "Set-vmhost-numaspanningenabled $false"

650) this.width=650; "height=" Bayi "title=" clip_image018 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image018 " Src= "http://s3.51cto.com/wyfs02/M02/77/00/wKioL1Zg4juylUk5AABD2mJfSdg739.jpg" border= "0"/>

5. Live Migration:

Windows Server R2 introduces a live migration that migrates a running virtual machine from one physical computer to another, without downtime or service disruption. However, this feature requires that virtual hard disks of the virtual machine remain consistent on the shared storage device, for example, on Fibre Channel or iscsis an. Starting with Windows Server 2012, live migration is no longer limited to clustering, and virtual machines can be migrated across cluster boundaries, including migrating to any Hyper-V home Server in the environment. Hyper-V adds support for parallel live migration on top of this feature, so you can migrate multiple virtual machines at the same time. Combined with network virtualization, this feature even enables easy migration of virtual machines between the local host and the Cloud host.

Hyper-V Live Migration supports migrating a running virtual machine from one physical host to another, without impacting the availability of virtual machines in the middle of a virtual user. Windows Server 2012 begins Hyper-V to introduce faster concurrent live migrations that can be migrated inside and outside the cluster environment. In addition to providing live migration in the most basic deployments, this feature supports more advanced scenarios, such as real-time migration of virtual machines between multiple independent clusters to balance the load across the database.

650) this.width=650; "height=" 292 "title=" clip_image020 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image020 " Src= "http://s3.51cto.com/wyfs02/M02/77/00/wKioL1Zg4jygNsUZAACv4gKCex0393.jpg" border= "0"/>

The settings for live migration are more complex to use with PowerShell and require relevant knowledge. The host that needs to be migrated must have the same domain or the same trust network, and the delegated account is a member of the Administrators group, and requires a specific network design, so here I first introduce the command set, in the following blog, there will be a special section dedicated to virtual machine dynamic migration.

The first is to use the: enable-vmmigration command to initiate an incoming and outgoing implementation migration:

650) this.width=650; "height=" "title=" clip_image021 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image021 " Src= "Http://s3.51cto.com/wyfs02/M01/77/01/wKiom1Zg4dXQ0bZAAAECudv5H68671.png" border= "0"/>

You are prompted to set up a migration network because you do not specify a network for live migration. If you turn off live migration, you need to perform disable-vmmigration. After the implementation transfer is turned on, the status of the live migration is detected by command Get-vmhost.

650) this.width=650; "height=" 146 "title=" clip_image023 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image023 " Src= "http://s3.51cto.com/wyfs02/M01/77/01/wKiom1Zg4dawrBb-AABbjaKKcXg687.jpg" border= "0"/>

After setting up the authentication protocol for live migration, there are 2 kinds of authentication protocols, one is CREDSSP and the other is Kerberos. CredSSP is a new security support provider (SSP) that is used by the Security Support Provider Interface (SSPI). Kerberos is a network authentication protocol designed to provide a powerful authentication service for client/server applications through a key system. The implementation of the authentication process does not depend on the authentication of the host operating system, no host address-based trust, no physical security of all hosts on the network, and assumes that packets sent over the network can be arbitrarily read, modified, and inserted into the data. In these cases, Kerberos acts as a trusted third-party authentication service through the use of traditional cryptography (e.g. shared secret keys) to perform authentication services.

650) this.width=650; "height=" "title=" clip_image025 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image025 " Src= "http://s3.51cto.com/wyfs02/M00/77/00/wKioL1Zg4kDT6HdwAAAsnyPKyeg681.jpg" border= "0"/>

The next step is to set the number of concurrent implementation migrations

650) this.width=650; "height=" "title=" clip_image027 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image027 " Src= "http://s3.51cto.com/wyfs02/M01/77/00/wKioL1Zg4kGxvs46AAAmGhuDjjw270.jpg" border= "0"/>

Incoming live migration, which is entered if you are using any network for live migration

650) this.width=650; "height=" "title=" clip_image029 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image029 " Src= "http://s3.51cto.com/wyfs02/M00/77/01/wKiom1Zg4diC5aLDAAAltWG9JqU962.jpg" border= "0"/>

If you specify an IP address to implement the migration, the IP address is followed by the line

650) this.width=650; "height=" title= "clip_image031" style= "Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image031 " Src= "http://s3.51cto.com/wyfs02/M01/77/01/wKiom1Zg4dmxDpHlAAAomWw4mE0698.jpg" border= "0"/>

6, storage migration is to transfer the files of the virtual machine to other places, and during the transfer process, the virtual machine has been operating, no downtime, and here is set the number of concurrent transfers stored.

Use PowerShell to set the number of storage migrations, set the number of concurrency here is 10, use the command: "Set-vmhost-maximumstoragemigrations 10"

650) this.width=650; "height=" 103 "title=" clip_image032 "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" clip_image032 " Src= "Http://s3.51cto.com/wyfs02/M00/77/00/wKioL1Zg4kShPK8bAAB88gcaNEk649.png" border= "0"/>

OK, these are some of the basic commands for managing Hyper-V with PowerShell! If you are interested you can go to Microsoft's website to download hyper-V PowerShell related information.

This article is from the "Wu Yuzhang Microsoft blog" blog, make sure to keep this source http://wuyvzhang.blog.51cto.com/9992636/1719409

Managing Hyper-V with PowerShell

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.