Sunday 28 August 2016

Essential PowerShell Cmdlets For Managing Hyper-V

Installing Hyper-V

Get-WindowsFeature Hyper-V

Get-WindowsOptionalFeature -FeatureName "Microsoft-Hyper-V" -Online | Format-Table

Install-WindowsFeature Hyper-V -Restart

To enable Hyper-V on Windows 10, use the following script:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Add-WindowsFeature RSAT-Hyper-V-Tools -IncludeAllSubFeature

Creating Virtual Machine Resources

New-item -itemType directory -Path ("C:\VM", C:\VM\iso") -Force


Creatign Virtual Switch

get-netadapter

New-VMSwitch -Name VMSwitch -NetAdapterName Ethernet
New-VMSwitch -Name VMSwitchInternal -SwitchType Private

Creating Virtual Hard Disk as a fixed size vhdx file
New-VHD -Path C:\VM\VH01.vhdx -Fixed -SizeBytes 10gb

Creating VMs
New-VM -Name "Ubuntu Desktop" -VHDPath .\UbuntuDesktop1.vhdx -MemoryStartupBytes 1024mb

New-VM -Name "Ubuntu Desktop Dynamic Disk" -NewVHDPath .\DynamicDisk.vhdx -NewVHDSizeBytes 10gb -MemoryStartupBytes 1024mb

Add-VMDvdDrive -VMName "Ubuntu Desktop" -Path .\iso\Ubuntu-16.04-desktop-amd64.iso




No comments:

Post a Comment