For detailed information, see the Checkpoint-VM reference documentation. The Checkpoint-VM cmdlet is used to create a checkpoint for a VM. The following example renames VM1 to VM2 and displays the renamed virtual machine: Rename-VM -ComputerName Server1 -Name VM1 -NewName VM2 For detailed information, see the Rename-VM reference documentation. The Rename-VM cmdlet is used to rename a VM. The following example exports a VM to the root of the D drive: Export-VM -ComputerName Server1 -Name VM1 -Path D:\ The VM is registered in-place, so its files are not copied: Import-VM -ComputerName Server1 -Name VM1 -Path 'C:\\2B91FEB3-F1E0-4FFF-B8BE-29CED892A95A.vmcx' The following example shows how to import a VM from its configuration file. For more information, see the Import-VM and Export-VM reference documentation. The following shows a couple of examples. The Import-VM and Export-VM cmdlets import and export a VM. The following example shows how to move a VM to Server2 from Server1 and move all files associated with the VM to D:\VM_name on the remote computer: Move-VM -ComputerName Server1 -Name VM1 -DestinationHost Server2 -IncludeStorage -DestinationStoragePath D:\VM_name The following example shows how to move a VM to Server2 when the VM is stored on an SMB share on Server1: Move-VM -ComputerName Server1 -Name VM1 -DestinationHost Server2 For more information, see the Move-VM reference documentation. The Move-VM cmdlet moves a VM to a different server. The following example shows how to shut-down a VM named TestVM: Stop-VM -Name VM1 -ComputerName Server1 The following example shows how to start a VM named VM1: Start-VM -Name VM1 -ComputerName Server1 For detailed information, see the Start-VM and Stop-VM reference documentation. Use the Start-VM and Stop-VM commands to start or stop a VM. Get-VM -ComputerName Server1 | Where-Object -Property State -eq "Off" The next example returns a list of all shut-down VMs on the server. Get-VM -ComputerName Server1 | Where-Object -Property State -eq "Running" For more information, see Using the Where-Object documentation. The following example returns a list of all running VMs on a server by adding a filter using the Where-Object command. The following example returns a list of all VMs on Server1. To create a virtual machine with a new virtual disk that boots to an operating system image, see the PowerShell example in Create virtual machine walkthrough for Hyper-V on Windows 10. \VMData -NewVHDSizeBytes 20GB -Generation 2 -SwitchName ExternalSwitch To create a virtual machine with a new virtual hard disk, replace the -VHDPath parameter from the example above with -NewVHDPath and add the -NewVHDSizeBytes parameter as shown here: New-VM -ComputerName Server1 -Name VM1 -MemoryStartupBytes 4GB -BootDevice VHD -NewVHDPath. The following parameters are used to specify virtual hard disks. \VMData -Generation 2 -SwitchName ExternalSwitch New-VM -ComputerName Server1 -Name VM1 -MemoryStartupBytes 4GB -BootDevice VHD -VHDPath. The virtual machine configuration files are stored in the folder VMData. It boots from the folder VMs\Win10.vhdx in the current directory and uses the virtual switch named ExternalSwitch. The next example creates a Generation 2 virtual machine with 4GB of memory. The full command as follows for creating a VM called VM1: New-VM -ComputerName Server1 -Name VM1 -MemoryStartupBytes -BootDevice -VHDPath -Path -Generation -SwitchName Get the name of the virtual switch by using Get-VMSwitch. SwitchName is the name of the virtual switch that you want the virtual machine to use to connect to other virtual machines or the network. Use generation 1 for VHD and generation 2 for VHDX. Generation is the virtual machine generation. Path is the path to store the virtual machine configuration files. VHDPath is the path to the virtual machine disk that you want to use. iso file for DVD-based boot, or a network adapter (NetworkAdapter) for network boot. Typically this is a virtual hard disk (VHD), an. BootDevice is the device that the virtual machine boots to when it starts. MemoryStartupBytes is the amount of memory that is available to the virtual machine at start up. Name is the name that you provide for the virtual machine that you're creating. Here are the settings that you can specify when creating a new VM with an existing virtual hard disk, where: For detailed usage, see the New-VM reference documentation. The New-VM cmdlet is used to create a new VM. NetBIOS names, IP addresses, and fully qualified domain names are allowable.įor the complete reference documentation for managing VMs using PowerShell, see Hyper-V reference. When running PowerShell commands from a management computer, include the -ComputerName parameter with the name of the host server you are managing.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |