PowerShell, of course, is integrated with just about every single piece of Microsoft technology these days. As the name applies, it's a 'powerful shell,' and through included or custom cmdlets can simplify and automate functions. A lot of times it takes only a single line of code to produce the desired result.

As more and more companies switch to using Microsoft's Hyper-V, managing the hypervisor becomes important, and PowerShell cmdlets are the key to success.

In this article I want to give you some simple commands that really work to help get you started. The cmdlets associated with the simple commands I'm including actually offer much more depth than what I'm providing, but they're a good start.

These commands must be run in a PowerShell instance and they all apply to Windows PowerShell 4.0, Windows 8.1, and Windows Server 2012 R2.

Creating a new VM

The following command simply creates a new VM instance called "myVM" and configures it to utilize 512MB of memory.

  1. New-VM –Name "myVM" –MemoryStartupBytes 512MB

Removing an Existing VM

The following command removes the VM called "myVM."

  1. Remove-VM "myVM"

Starting an Existing VM

The following command takes a VM called "myVM" and makes it active.

  1. Start-VM –Name myVM

Stop a Running VM

This command will halt the VM called "myVM."

  1. Stop-VM –Name myVM

Pause a Running VM

Instead of just stopping a VM completely, this command will pause (or suspend) the VM called "myVM."

  1. Suspend-VM –Name myVM

Restart a Paused VM

This command resumes the "myVM" VM that has been paused using the Suspend-VM command.

  1. Resume-VM –Name myVM

Save and Hibernate a VM

The following command saves the current running configuration of the "myVM" VM and puts it to sleep. This is similar to when a computer hibernates.

  1. Save-VM –Name myVM

Changing the Name of a VM

If you don't like the name of a VM, or need to make adjustments based on company policy, the following command will enable you to do change the VM name. This command changes "myVM" to "yourVM."

  1. Rename-VM myVM –NewName yourVM

Moving a VM to another Hyper-V Server

If you need to migrate a current VM to a remote Hyper-V host, this command will do it. This moves "myVM" to a server called "Tatooine."

  1. Move-VM “myVM” Tatooine

Export and Importing a Working VM

The Export and Import VM commands are pretty useful and work great together. Using the Export command you can take a good, working VM and export it to disk. The following command exports "myVM" to a local drive and path (D:\myVMDirectory).

  1. Export-VM –Name myVM –Path D:\myVMDirectory

Alternatively, you can use the Import command to pull an exported VM from the file path into the Hyper-V host. Make sure to include the full path and exported filename.

  1. Import-VM –Path 'D:\myVMDirectory\VMFileName.XML'