Monday, March 19, 2012

Handy PowerShell tasks for Hyper-V in Windows 8

Okay, so you have committed yourself to learning how to use PowerShell and you have the Windows 8 Server Beta.

You don’t want to write all kinds of fancy scripts, you just want to do the same tasks that you did in the GUI.  And for increased pain (forced learning) you even installed Server Core or Hyper-V Server.

Here are a few of those good old one-off type of actions that we have grown used to, but using PowerShell to drive them.

This should introduce you to doing tasks using PowerShell as well as getting started with the Hyper-V cmdlets.

Create a new VM:

New-VM or

New-VM –Name “DemoVM” or

New-VM -Name "DemoVM" -MemoryStartupBytes 2gb -bootdevice HardDrive -SwitchName Lab -path C:\users\public\documents -NewVHDSizeBytes 36gb –NewVHDPath C:\users\public\documents\DemoVM

Insert an ISO into the virtual DVD drive:

Set-VMDvdDrive –VMName DemoVM -Path C:\users\public\Documents\DemoOSInstaller.iso

Boot the VM:

Start-VM –Name DemoVM

Launch a VMConnect VM Console (after all you have a clean OS to install and all you have is the beta ISO):

vmconnect localhost DemoVM

Eject the DVD from the virtual DVD drive:

Set-VMDvdDrive –VMName DemoVM -Path $NULL

No comments: