Windows PowerShell scripts related to VDI

Source: Internet
Author: User

When Windows 8.1 and Windows Server 2012 R2 were officially released, Microsoft also provided the new PowerShell version. At least half of the scripts can help the VDI administrator process daily or routine management tasks.

You can use Windows PowerShell scripts through the huge Hyper-V cmdlet library in Windows 8.1 and Windows Server 2012 R2.

Not only for virtual servers

There are a total of 164 Hyper-V cmdlet in the database, most of which are valuable to the VDI administrator. Data also shows that VDI automation can reduce the amount of manual management tasks that administrators must handle, especially in desktop configuration and update.

Table 1 selects the project list from the section referenced by TechNet. Each cmdlet is linked to the corresponding English document page.

Table 1: VDI Hyper-V cmdlet

CMdlet

 Description

Add-VMDvdDrive Install the DVD drive on the VM.
Add-VMHardDiskDrive Install the hard drive on the VM.
Add-VMMigrationNetwork Add the network to the network list for VM migration.
Checkpoint-VM Create a VM snapshot.
Connect-VMNetworkAdapter Connect the virtual network adapter to the virtual network.
Convert-VHD By copying the source file to a new file, convert the format or type of the virtual hard disk file on the VM to VHDX or VHD format.
Copy-VMFile Copy the file to the VM.
Disconnect-VMNetworkAdapter Disconnect the virtual network adapter from the virtual network or network resource pool.
Dismount-VHD Specifies the file path when uninstalling VHD.
Grant-VMConnectAccess Allows a user to connect to a VM, which is usually used to authorize other applications to enable VM session permissions.
Get-VM Retrieve VMObject for each VM on the Hyper-V host.
Import-VM Import VM from a given folder.
Measure-VM Search resource utilization data of existing virtual machines, including CPU and memory usage, network traffic, and disk capacity.
Merge-VHD Combine VHD with a differential VHD chain to Hyper-V.
Mount-VHD Install the specified VHD in one or more VHD files.
Move-VMStorage Specifies the path to move the VM storage.
New-VMResourcePool Create a resource pool on the Hyper-V host. Default local computer.
Remove-VM Delete the configuration file of an existing VM, but do not delete the configuration file on VHD.
Repair-VM Use the fix in the compatibility report to restore the VM to a more stable state.
Resize-VHD Zoom in or out the VHD size.

Other PowerShell information that the VDI administrator is interested in

PowerShell itself will show you how to use these scripts: Simply enter Get-Command-Module Hyper-V in the PowerShell window and you will Get a complete list related to the latest Hyper-V version.

You can search for these cmdlet types by verb, such as adding, copying, granting, obtaining, installing, moving, deleting, and adjusting. What you need to do is add-Name * search * after Get-Command in the input, and * use the string that you are actually interested in to add, copy, and install, you will get what you want. The Get-help cmdlet command receives the name of the input cmdlet. You can append the following command to obtain more information.

-Examples: Code instance

-Detailed: Detailed output

-Full: All Information

To access the Hyper-V module in PowerShell, you must first open it. Run the management permission in the PowerShell window) enter the following command string:

Add-WindowsFeature Hyper-V-IncludeManagementTools

If you want to use and manage Hyper-V, you need to Run the PowerShell console as an "administrator" right-click and select Run as administrator from the pop-up menu ). Once started and run, you will find PowerShell is an invaluable VDI management tool.

PowerShell 4.0 is very new, and TechNet documents have not updated the latest released code library. You must obtain Windows Management Framework 4.0 preview from TechNet before using PowerShell 4.0. The Windows Management Framework 4.0 preview is very close to the final content, applicability, code, and details.

Related Article

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.