---
title: "Hyper-V PowerShell module : Getting More Things Done"
description: "If you are a newbie and you desire to learn what Hyper-V is, what it is used for, and how to manage Virtual Machines with Hyper-V and with Hyper-V PowerShell Commands, then this article is for you."
canonical: "https://adamtheautomator.com/hyper-v-powershell/"
---

# Hyper-V PowerShell module : Getting More Things Done

> If you are a newbie and you desire to learn what Hyper-V is, what it is used for, and how to manage Virtual Machines with Hyper-V and with Hyper-V PowerShell Commands, then this article is for you.

Source: https://adamtheautomator.com/hyper-v-powershell/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Hyper-V PowerShell module : Getting More Things Done](https://adamtheautomator.com/wp-content/uploads/2021/04/Getting-Started-Guide-to-Managing-Hyper-V-VMs-with-PowerShell.jpg)

# Hyper-V PowerShell module : Getting More Things Done

[![](https://secure.gravatar.com/avatar/4857309ffa2757ccd895816d23abcbed03b21a0557487e69114a512023cfc095?s=192&d=mm&r=g)Deborah Emeni](https://adamtheautomator.com/author/deborah-emeni/)28 April 20215 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[hyper-v](/tag/hyper-v/)[PowerShell](/tag/powershell/)

Table of Contents

*   [Prerequisites](#h-prerequisites)
*   [Connecting to a Remote Hyper-V Host](#h-connecting-to-a-remote-hyper-v-host)
*   [Creating Hyper-V VMs with PowerShell](#h-creating-hyper-v-vms-with-powershell)
*   [Creating a Simple VM](#h-creating-a-simple-vm)
*   [Creating a VM Based on Other VM Attributes](#h-creating-a-vm-based-on-other-vm-attributes)
*   [Listing Existing VMs with PowerShell](#h-listing-existing-vms-with-powershell)
*   [Starting and Stopping VMs](#h-starting-and-stopping-vms)
*   [Modifying Hyper-V VMs](#h-modifying-hyper-v-vms)
*   [Saving Hyper-V VMs](#h-saving-hyper-v-vms)
*   [Managing Hyper-V VM Checkpoints](#h-managing-hyper-v-vm-checkpoints)
*   [Conclusion](#h-conclusion)

If you’re using Microsoft’s Hyper-V virtualization platform to run virtual machines, you’re probably familiar with using the Hyper-V Manager. But did you know you can get more done in less time with the Hyper-V PowerShell module?

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

In this tutorial, you’re going to learn how to manage Hyper-V VMs with PowerShell including creating, removing and you’ll also get into VM snapshots!

Related:[How to Manage Hyper-V Hosts from a Non-Domain Windows Client](https://adamtheautomator.com/hyper-v-host/)

## Prerequisites

For this tutorial, you will need the following listed below:

*   A Windows client to connect to a remote Hyper-V host. This tutorial uses Windows 10 Pro.
*   A Hyper-V host with [PowerShell Remoting enabled](https://adamtheautomator.com/enable-psremoting/). The tutorial’s Hyper-V host is named HYPER and is in a workgroup but an Active-Directory joined client and host will work as well.
*   A user account on the Hyper-V host in the local administrators group or in the Hyper-V Administrators group. This tutorial will use an account called _localadmin_.

## Connecting to a Remote Hyper-V Host

To work with Hyper-V on PowerShell, you must be able to communicate with the Hyper-V host somehow. You can either do that locally by running the Hyper-V PowerShell cmdlets providing the name of the Hyper-V host or you can use PowerShell Remoting to connect to the Hyper-V host itself.

In this tutorial, you will make a persistent connection to the Hyper-V host and run the commands on the Hyper-V host itself.

Related:[How to Set up PSRemoting with WinRM and SSL \[Step by Step\]](https://adamtheautomator.com/winrm-ssl/)

1\. Open PowerShell on your local computer.

2\. Run the `Enter-PSSession` cmdlet providing the hostname of your remote Hyper-V host for the `ComputerName` parameter. This action creates an interactive session and allows you to run commands interactively on the remote Hyper-V host.

```powershell
Enter-PSSession -ComputerName HYPER -Credential (Get-Credential)
```

> _If your client and Hyper-V host are a member of the same Active Directory domain, you do not have to use the `Credential` parameter._

3\. You will then be prompted for a username and password to connect to the Hyper-V host. This username and password will be a local administrative user on the remote host. Once connected, you should see your PowerShell prompt has changed to show the hostname of the Hyper-V host.

You are now ready to start running commands!

## Creating Hyper-V VMs with PowerShell

Assuming you’re now connected to your Hyper-V host using PowerShell Remoting, let’s start running commands by creating a Hyper-V VM.

### Creating a Simple VM

While in your PSRemoting session connected to the remote Hyper-V host:

Run the `New-VM` cmdlet to create a new VM. When creating a VM with the `New-VM` cmdlet, you have many different options to choose from on how to create it.

1\. In this example below, the tutorial is creating a VM with:

*   A name of MyVM (`HYPER`)
*   512MB of RAM (`MemoryStartupBytes`)

```powershell
New-VM -Name "HYPER" -MemoryStartupBytes 512MB
```

![New VM named "HYPER"](https://adamtheautomator.com/wp-content/uploads/2021/04/New_VM_MA.jpeg)

New VM named “HYPER”

### Creating a VM Based on Other VM Attributes

Sometimes you need to create a VM with similar attributes to another VM. You can do that but assign various VM attributes to variables and then use those variables when creating the new VM. As an example:

1\. Run `Get-VM` to query attributes of an existing VM assigning the output to a variable as shown below.

```powershell
$VMold = Get-VM "HYPER_old"
```

2\. Run the `Get-VMMemory` cmdlet providing the name of the VM to gather attributes from (in this case, memory), and assign the memory value to a variable.

```powershell
$memory = (Get-VMMemory -VMName $VMold.name).Startup
```

3\. Next, create a new VM with the `New-VM` cmdlet providing the `Name`, VM generation (`Generation`) using the `Generation` property from the other VM, and amount of memory from the value obtained from the other VM.

```powershell
New-VM -Name "newVM" -Generation $VMold.Generation -MemoryStartupBytes $memory
```

![New VM created from Old existing VM](https://adamtheautomator.com/wp-content/uploads/2021/04/New_VM_example_2.jpeg)

New VM created from Old existing VM

## Listing Existing VMs with PowerShell

Now that you have at least two VMs created on the Hyper-V host let’s explore how to enumerate created VMs. To do that:

1\. Run the `Get-VM` cmdlet by itself. When you run with no parameters, `Get-VM` queries the Hyper-V host for all existing VMs. `Get-VM`

```powershell
Get-VM
```

![Output of Get-VM run with no Parameters](https://adamtheautomator.com/wp-content/uploads/2021/04/MA_Get-Vm.jpeg)

Output of Get-VM run with no Parameters

2\. Perhaps you’d like to only look for a single VM. In that case, use the `-Name` parameter. The below code command is querying Hyper-V for the VM created earlier named `HYPER_old`. `Get-VM -Name HYPER_old`

```powershell
Get-VM -Name HYPER_old
```

![Output of Get-VM run with the -Name Parameter](https://adamtheautomator.com/wp-content/uploads/2021/04/MA2_GetVM-1.jpeg)

Output of Get-VM run with the -Name Parameter

Next, maybe you need to find all VMs that are in a specific `State`. No problem. To do that, run `Get-VM`, which queries all VMs but pipe the output to the `Where-Object` cmdlet.

Related:[How to Use PowerShell’s Where-Object to Filter All the Things](https://adamtheautomator.com/powershell-where-object/)

In the example below, the Pipe ‘|’ limits `Get-VM`‘s output to only those VM objects with a `State` of `Running`. `Get-VM -VMName HYPER_old | Where-Object {$_.State -eq 'Running'}`

```powershell
Get-VM -VMName HYPER_old | Where-Object {$_.State -eq 'Running'}
```

![Output of Get-VM filtering out the VM with the state of Running](https://adamtheautomator.com/wp-content/uploads/2021/04/MA_Filter_GET_VM-1.jpeg)

Output of Get-VM filtering out the VM with the state of Running

## Starting and Stopping VMs

At this time, the VM created earlier is probably stopped. Let’s change that by starting it and then learning how to stop VMs also.

In the remote Hyper-V host’s PowerShell session:

1\. Run the `Start-VM` cmdlet providing it the name (`Name`) of the VM created earlier with the `-Name` parameter

```powershell
Start-VM -Name NewVM
```

![The Start-VM command starting the VM named HYPER\_old](https://adamtheautomator.com/wp-content/uploads/2021/04/MA_StartVM-1.jpg)

The Start-VM command starting the VM named HYPER\_old

Now that the VM is started, stop it by using the `Stop-VM` cmdlet providing the name of the VM with the `Name` parameter.

```powershell
Stop-VM -Name HYPER_old
```

As soon as you run the command above, you will see the VM shutting down as seen in the screenshot below;

![Stop-VM stopping the HYPER\_old VM](https://adamtheautomator.com/wp-content/uploads/2021/04/MA_Stop_VM_.jpg)

Stop-VM stopping the HYPER\_old VM

## Modifying Hyper-V VMs

VMs don’t always stay the same. Maybe you need to increase the CPU resources, or the VM is consistently running out of memory. In that case, the `Set-VM` cmdlet is your friend.

As an example of modifying existing VMs, in the remote Hyper-V host’s PowerShell session:

Run the `Set-VM` cmdlet to automatically shutdown the HYPER\_old VM that is currently running. Use the `Name` parameter to specify the VM you want to set and specify `Shutdown` as the value for the `AutomaticStopAction` parameter to ensure the VM is automatically shut down properly when the Hyper-V host is shut down.

```powershell
Set-VM -Name HYPER_old -AutomaticStopAction Shutdown
```

## Saving Hyper-V VMs

In the remote Hyper-V host’s PowerShell session, you may need to save the VM you create to preserve the state of the VM’s memory for later use. To do this, use the `Save-VM` cmdlet with the `Name` parameter specifying the name of the VM that you want to save.

> _Note that, the VM that you want to save must be in a Running state._

```powershell
Save-VM -Name HYPER_old
```

![Save-VM cmdlet saving HYPER\_old VM state.](https://adamtheautomator.com/wp-content/uploads/2021/04/MA_Save_VM.jpg)

Save-VM cmdlet saving HYPER\_old VM state.

## Managing Hyper-V VM Checkpoints

If you need to save the existing state of a VM before making changes or revert VM changes, you should learn about [checkpoints](https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/checkpoints). Checkpoints are a handy way to quickly save the disk and memory state of any Hyper-V VM.

While on your Hyper-V host, run the [`Checkpoint-VM`](https://docs.microsoft.com/en-us/powershell/module/hyper-v/checkpoint-vm?view=windowsserver2019-ps) cmdlet, providing the VM’s name to save and a name for the checkpoint.

> _The parameter name, `SnapshotName` still references the old terminology used in Hyper-V 2012. A snapshot is the same thing as a checkpoint._

```powershell
Checkpoint-VM -Name HYPER_old -SnapshotName MyVMSnapshot
```

![Using Checkpoint-VM to create a Snapshot of HYPER\_old VM called MyVMSnapshot](https://adamtheautomator.com/wp-content/uploads/2021/04/MA_Checkpoint.jpg)

Using Checkpoint-VM to create a Snapshot of HYPER\_old VM called MyVMSnapshot

Once you have a checkpoint created, you can then use the [`Get-VMSnapshot`](https://docs.microsoft.com/en-us/powershell/module/hyper-v/get-vmsnapshot?view=windowsserver2019-ps) cmdlet to retrieve all of the snapshots stored on the Hyper-V host. You can see below the VM HYPER\_old has three checkpoints.

```powershell
Get-VMSnapshot -VMName HYPER_old
```

![Retrieves all the Snapshots stored for HYPER\_old VM](https://adamtheautomator.com/wp-content/uploads/2021/04/MA_last_checkpoint.jpg)

Retrieves all the Snapshots stored for HYPER\_old VM

## Conclusion

If you’ve worked through all of the demos in this tutorial, you are well on your way to managing Hyper-V VMs with PowerShell. You should now have the knowledge required to manage 1, 10, or even 100 VMs!

What kind of tasks do you think you can now automate with PowerShell and Hyper-V?

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fhyper-v-powershell%2F&text=Hyper-V%20PowerShell%20module%20%3A%20Getting%20More%20Things%20Done)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fhyper-v-powershell%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fhyper-v-powershell%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

![](https://adamtheautomator.com/wp-content/uploads/2025/06/featured-image-6.png)

### [How to Add Timeouts to Pester Tests with PowerShell Runspaces](/pester-test-timeout-runspaces/)

Prevent Pester tests from hanging indefinitely using PowerShell runspaces. Learn to handle variable scoping, module loading, TestDrive access, and stream capture challenges with timeout protection.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
