Getting Started Guide to Managing Hyper

choubertsprojects

The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

Hyper is a decentralized, open-source platform that allows users to exchange online files in an encrypted manner. Hyper was created with the intention of providing its community with a simple and effective way to store their personal data.

The “start hyper-v manager from command line” is a guide for those who are new to managing Hyper-V. It provides step by step instructions on how to start the Hyper-V Manager in Windows 10.

Getting Started Guide to Managing Hyper

You’re undoubtedly acquainted with the Hyper-V Manager if you use Microsoft’s Hyper-V virtualization framework to operate virtual machines. But did you know that the Hyper-V PowerShell module may help you get more done in less time?

You’ll learn how to manage Hyper-V VMs using PowerShell in this article, including how to create, remove, and manage VM snapshots!

How to Manage Hyper-V Hosts from a Windows Non-Domain Client

Prerequisites

You’ll need the following items to complete this tutorial:

  • A Windows client for connecting to a Hyper-V host from afar. The operating system used in this lesson is Windows 10 Pro.
  • PowerShell Remoting is enabled on a Hyper-V host. The Hyper-V host in this lesson is called HYPER and is part of a workgroup, although an Active-Directory linked client and host will also function.
  • A user account in the local administrators group or the Hyper-V Administrators group on the Hyper-V server. This tutorial will make use of the account localadmin.

Connecting to a Hyper-V Host from afar

To use PowerShell with Hyper-V, you must be able to interface with the Hyper-V host in some way. You may accomplish this locally by using the Hyper-V PowerShell cmdlets and specifying the Hyper-V host’s name, or you can use PowerShell Remoting to connect to the Hyper-V server.

You will establish a persistent connection to the Hyper-V host and conduct the instructions on the Hyper-V server itself in this tutorial.

Related: [Step-by-Step] How to Set Up PSRemoting with WinRM and SSL

1. On your local computer, launch PowerShell.

2. Run the Enter-PSSession cmdlet with the ComputerName option set to the hostname of your remote Hyper-V machine. This operation initiates an interactive session, allowing you to perform commands on the remote Hyper-V server interactively.

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

You don’t need to utilize the Credential argument if your client and Hyper-V host are both members of the same Active Directory domain.

3. To connect to the Hyper-V host, you’ll be asked for a username and password. On the remote computer, this username and password will be for a local administrator account. When you’re connected, your PowerShell prompt should update to indicate the Hyper-V host’s hostname.

You’re all set to begin executing commands!

Using PowerShell to create Hyper-V VMs

Let’s start executing commands by constructing a Hyper-V VM, assuming you’re now connected to your Hyper-V host using PowerShell Remoting.

Creating a Basic Virtual Machine

While connected to the remote Hyper-V host using PSRemoting:

To build a new VM, use the New-VM cmdlet. When using the New-VM cmdlet to build a virtual machine, you have a variety of choices to pick from.

1. In the following example, the instruction is constructing a virtual machine with:

  • MyVM’s moniker (HYPER)
  • 512 megabytes of RAM (MemoryStartupBytes)

-MemoryStartupBytes 512MB -New-VM -Name “HYPER”

New VM named "HYPER"“HYPER” is a new virtual machine.

Creating a Virtual Machine Using Other VM Attributes

You may need to construct a VM with properties that are comparable to those of another VM. You may accomplish that by assigning different VM properties to variables, which you can then utilize to create the new VM. Consider the following scenario:

1. Use Get-VM to query the properties of an existing virtual machine and save the results to a variable, as shown below.

Get-VM “HYPER old” $VMold = Get-VM “HYPER old”

2. Run the Get-VMMemory cmdlet with the name of the VM you want to collect characteristics from (in this example, memory) and set the memory value to a variable.

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

3. Next, use the New-VM cmdlet to create a new VM with the Name, VM generation (Generation) from the other VM’s Generation property, and amount of RAM from the other VM’s value.

$VMold.Generation -MemoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memory

An old VM was used to build a new one.An old VM was used to build a new one.

Using PowerShell to list existing VMs

Let’s look at how to enumerate generated VMs now that you’ve built at least two on the Hyper-V host. To do so, follow these steps:

1. Simply run the Get-VM cmdlet. Get-VM searches the Hyper-V host for all existing VMs when called without arguments. Get-VM

Get-VM output when performed without parametersGet-VM output when performed without parameters

2. Perhaps you simply want to seek for a single virtual machine. Use the -Name argument in such scenario. The code below searches Hyper-V for the VM called HYPER old that was built before. Get-VM HYPER old -Name

Get-VM output using the -Name parameter.Get-VM output using the -Name parameter.

Following that, you may need to locate all VMs that are in a given State. It’s no issue. Run Get-VM, which will query all VMs and send the results to the Where-Object cmdlet.

How to Use the Where-Object in PowerShell to Filter Everything

The Pipe ‘|’ in the example below restricts Get-output VM’s to to those VM objects that have a State of Running. Where-Object

You’re undoubtedly acquainted with the Hyper-V Manager if you use Microsoft’s Hyper-V virtualization framework to operate virtual machines. But did you know that the Hyper-V PowerShell module may help you get more done in less time?

You’ll learn how to manage Hyper-V VMs using PowerShell in this article, including how to create, remove, and manage VM snapshots!

How to Manage Hyper-V Hosts from a Windows Non-Domain Client

Prerequisites

You’ll need the following items to complete this tutorial:

  • A Windows client for connecting to a Hyper-V host from afar. The operating system used in this lesson is Windows 10 Pro.
  • PowerShell Remoting is enabled on a Hyper-V host. The Hyper-V host in this lesson is called HYPER and is part of a workgroup, although an Active-Directory linked client and host will also function.
  • A user account in the local administrators group or the Hyper-V Administrators group on the Hyper-V server. This tutorial will make use of the account localadmin.

Connecting to a Hyper-V Host from afar

To use PowerShell with Hyper-V, you must be able to interface with the Hyper-V host in some way. You may accomplish this locally by using the Hyper-V PowerShell cmdlets and specifying the Hyper-V host’s name, or you can use PowerShell Remoting to connect to the Hyper-V server.

You will establish a persistent connection to the Hyper-V host and conduct the instructions on the Hyper-V server itself in this tutorial.

Related: [Step-by-Step] How to Set Up PSRemoting with WinRM and SSL

1. On your local computer, launch PowerShell.

2. Run the Enter-PSSession cmdlet with the ComputerName option set to the hostname of your remote Hyper-V machine. This operation initiates an interactive session, allowing you to perform commands on the remote Hyper-V server interactively.

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

You don’t need to utilize the Credential argument if your client and Hyper-V host are both members of the same Active Directory domain.

3. To connect to the Hyper-V host, you’ll be asked for a username and password. On the remote computer, this username and password will be for a local administrator account. When you’re connected, your PowerShell prompt should update to indicate the Hyper-V host’s hostname.

You’re all set to begin executing commands!

Using PowerShell to create Hyper-V VMs

Let’s start executing commands by constructing a Hyper-V VM, assuming you’re now connected to your Hyper-V host using PowerShell Remoting.

Creating a Basic Virtual Machine

While connected to the remote Hyper-V host using PSRemoting:

To build a new VM, use the New-VM cmdlet. When using the New-VM cmdlet to build a virtual machine, you have a variety of choices to pick from.

1. In the following example, the instruction is constructing a virtual machine with:

  • MyVM’s moniker (HYPER)
  • 512 megabytes of RAM (MemoryStartupBytes)

-MemoryStartupBytes 512MB -New-VM -Name “HYPER”

New VM named "HYPER"“HYPER” is a new virtual machine.

Creating a Virtual Machine Using Other VM Attributes

You may need to construct a VM with properties that are comparable to those of another VM. You may accomplish that by assigning different VM properties to variables, which you can then utilize to create the new VM. Consider the following scenario:

1. Use Get-VM to query the properties of an existing virtual machine and save the results to a variable, as shown below.

Get-VM “HYPER old” $VMold = Get-VM “HYPER old”

2. Run the Get-VMMemory cmdlet with the name of the VM you want to collect characteristics from (in this example, memory) and set the memory value to a variable.

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

3. Next, use the New-VM cmdlet to create a new VM with the Name, VM generation (Generation) from the other VM’s Generation property, and amount of RAM from the other VM’s value.

$VMold.Generation -MemoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memory

An old VM was used to build a new one.An old VM was used to build a new one.

Using PowerShell to list existing VMs

Let’s look at how to enumerate generated VMs now that you’ve built at least two on the Hyper-V host. To do so, follow these steps:

1. Simply run the Get-VM cmdlet. Get-VM searches the Hyper-V host for all existing VMs when called without arguments. Get-VM

Get-VM output when performed without parametersGet-VM output when performed without parameters

2. Perhaps you simply want to seek for a single virtual machine. Use the -Name argument in such scenario. The code below searches Hyper-V for the VM called HYPER old that was built before. Get-VM HYPER old -Name

Get-VM output using the -Name parameter.Get-VM output using the -Name parameter.

Following that, you may need to locate all VMs that are in a given State. It’s no issue. Run Get-VM, which will query all VMs and send the results to the Where-Object cmdlet.

How to Use the Where-Object in PowerShell to Filter Everything

In the example below, the Pipe ‘|’ limits Get-VM‘s output to only those VM objects with a State of Running. Where-Object

You’re undoubtedly acquainted with the Hyper-V Manager if you use Microsoft’s Hyper-V virtualization framework to operate virtual machines. But did you know that the Hyper-V PowerShell module may help you get more done in less time?

You’ll learn how to manage Hyper-V VMs using PowerShell in this article, including how to create, remove, and manage VM snapshots!

How to Manage Hyper-V Hosts from a Windows Non-Domain Client

Prerequisites

You’ll need the following items to complete this tutorial:

  • A Windows client for connecting to a Hyper-V host from afar. The operating system used in this lesson is Windows 10 Pro.
  • PowerShell Remoting is enabled on a Hyper-V host. The Hyper-V host in this lesson is called HYPER and is part of a workgroup, although an Active-Directory linked client and host will also function.
  • A user account in the local administrators group or the Hyper-V Administrators group on the Hyper-V server. This tutorial will make use of the account localadmin.

Connecting to a Hyper-V Host from afar

To use PowerShell with Hyper-V, you must be able to interface with the Hyper-V host in some way. You may accomplish this locally by using the Hyper-V PowerShell cmdlets and specifying the Hyper-V host’s name, or you can use PowerShell Remoting to connect to the Hyper-V server.

You will establish a persistent connection to the Hyper-V host and conduct the instructions on the Hyper-V server itself in this tutorial.

Related: [Step-by-Step] How to Set Up PSRemoting with WinRM and SSL

1. On your local computer, launch PowerShell.

2. Run the Enter-PSSession cmdlet with the ComputerName option set to the hostname of your remote Hyper-V machine. This operation initiates an interactive session, allowing you to perform commands on the remote Hyper-V server interactively.

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

You don’t need to utilize the Credential argument if your client and Hyper-V host are both members of the same Active Directory domain.

3. To connect to the Hyper-V host, you’ll be asked for a username and password. On the remote computer, this username and password will be for a local administrator account. When you’re connected, your PowerShell prompt should update to indicate the Hyper-V host’s hostname.

You’re all set to begin executing commands!

Using PowerShell to create Hyper-V VMs

Let’s start executing commands by constructing a Hyper-V VM, assuming you’re now connected to your Hyper-V host using PowerShell Remoting.

Creating a Basic Virtual Machine

While connected to the remote Hyper-V host using PSRemoting:

To build a new VM, use the New-VM cmdlet. When using the New-VM cmdlet to build a virtual machine, you have a variety of choices to pick from.

1. In the following example, the instruction is constructing a virtual machine with:

  • MyVM’s moniker (HYPER)
  • 512 megabytes of RAM (MemoryStartupBytes)

-MemoryStartupBytes 512MB -New-VM -Name “HYPER”

New VM named "HYPER"“HYPER” is a new virtual machine.

Creating a Virtual Machine Using Other VM Attributes

You may need to construct a VM with properties that are comparable to those of another VM. You may accomplish that by assigning different VM properties to variables, which you can then utilize to create the new VM. Consider the following scenario:

1. Use Get-VM to query the properties of an existing virtual machine and save the results to a variable, as shown below.

Get-VM “HYPER old” $VMold = Get-VM “HYPER old”

2. Run the Get-VMMemory cmdlet with the name of the VM you want to collect characteristics from (in this example, memory) and set the memory value to a variable.

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

3. Next, use the New-VM cmdlet to create a new VM with the Name, VM generation (Generation) from the other VM’s Generation property, and amount of RAM from the other VM’s value.

$VMold.Generation -MemoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memory

An old VM was used to build a new one.An old VM was used to build a new one.

Using PowerShell to list existing VMs

Let’s look at how to enumerate generated VMs now that you’ve built at least two on the Hyper-V host. To do so, follow these steps:

1. Simply run the Get-VM cmdlet. Get-VM searches the Hyper-V host for all existing VMs when called without arguments. Get-VM

Get-VM output when performed without parametersGet-VM output when performed without parameters

2. Perhaps you simply want to seek for a single virtual machine. Use the -Name argument in such scenario. The code below searches Hyper-V for the VM called HYPER old that was built before. Get-VM HYPER old -Name

Get-VM output using the -Name parameter.Get-VM output using the -Name parameter.

Following that, you may need to locate all VMs that are in a given State. It’s no issue. Run Get-VM, which will query all VMs and send the results to the Where-Object cmdlet.

How to Use the Where-Object in PowerShell to Filter Everything

The Pipe ‘|’ in the example below restricts Get-output VM’s to to those VM objects that have a State of Running. Where-Object

You’re undoubtedly acquainted with the Hyper-V Manager if you use Microsoft’s Hyper-V virtualization framework to operate virtual machines. But did you know that the Hyper-V PowerShell module may help you get more done in less time?

You’ll learn how to manage Hyper-V VMs using PowerShell in this article, including how to create, remove, and manage VM snapshots!

How to Manage Hyper-V Hosts from a Windows Non-Domain Client

Prerequisites

You’ll need the following items to complete this tutorial:

  • A Windows client for connecting to a Hyper-V host from afar. The operating system used in this lesson is Windows 10 Pro.
  • PowerShell Remoting is enabled on a Hyper-V host. The Hyper-V host in this lesson is called HYPER and is part of a workgroup, although an Active-Directory linked client and host will also function.
  • A user account in the local administrators group or the Hyper-V Administrators group on the Hyper-V server. This tutorial will make use of the account localadmin.

Connecting to a Hyper-V Host from afar

To use PowerShell with Hyper-V, you must be able to interface with the Hyper-V host in some way. You may accomplish this locally by using the Hyper-V PowerShell cmdlets and specifying the Hyper-V host’s name, or you can use PowerShell Remoting to connect to the Hyper-V server.

You will establish a persistent connection to the Hyper-V host and conduct the instructions on the Hyper-V server itself in this tutorial.

Related: [Step-by-Step] How to Set Up PSRemoting with WinRM and SSL

1. On your local computer, launch PowerShell.

2. Run the Enter-PSSession cmdlet with the ComputerName option set to the hostname of your remote Hyper-V machine. This operation initiates an interactive session, allowing you to perform commands on the remote Hyper-V server interactively.

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

You don’t need to utilize the Credential argument if your client and Hyper-V host are both members of the same Active Directory domain.

3. To connect to the Hyper-V host, you’ll be asked for a username and password. On the remote computer, this username and password will be for a local administrator account. When you’re connected, your PowerShell prompt should update to indicate the Hyper-V host’s hostname.

You’re all set to begin executing commands!

Using PowerShell to create Hyper-V VMs

Let’s start executing commands by constructing a Hyper-V VM, assuming you’re now connected to your Hyper-V host using PowerShell Remoting.

Creating a Basic Virtual Machine

While connected to the remote Hyper-V host using PSRemoting:

To build a new VM, use the New-VM cmdlet. When using the New-VM cmdlet to build a virtual machine, you have a variety of choices to pick from.

1. In the following example, the instruction is constructing a virtual machine with:

  • MyVM’s moniker (HYPER)
  • 512 megabytes of RAM (MemoryStartupBytes)

-MemoryStartupBytes 512MB -New-VM -Name “HYPER”

New VM named "HYPER"“HYPER” is a new virtual machine.

Creating a Virtual Machine Using Other VM Attributes

You may need to construct a VM with properties that are comparable to those of another VM. You may accomplish that by assigning different VM properties to variables, which you can then utilize to create the new VM. Consider the following scenario:

1. Use Get-VM to query the properties of an existing virtual machine and save the results to a variable, as shown below.

Get-VM “HYPER old” $VMold = Get-VM “HYPER old”

2. Run the Get-VMMemory cmdlet with the name of the VM you want to collect characteristics from (in this example, memory) and set the memory value to a variable.

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

3. Next, use the New-VM cmdlet to create a new VM with the Name, VM generation (Generation) from the other VM’s Generation property, and amount of RAM from the other VM’s value.

$VMold.Generation -MemoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memory

An old VM was used to build a new one.An old VM was used to build a new one.

Using PowerShell to list existing VMs

Let’s look at how to enumerate generated VMs now that you’ve built at least two on the Hyper-V host. To do so, follow these steps:

1. Simply run the Get-VM cmdlet. Get-VM searches the Hyper-V host for all existing VMs when called without arguments. Get-VM

Get-VM output when performed without parametersGet-VM output when performed without parameters

2. Perhaps you simply want to seek for a single virtual machine. Use the -Name argument in such scenario. The code below searches Hyper-V for the VM called HYPER old that was built before. Get-VM HYPER old -Name

Get-VM output using the -Name parameter.Get-VM output using the -Name parameter.

Following that, you may need to locate all VMs that are in a given State. It’s no issue. Run Get-VM, which will query all VMs and send the results to the Where-Object cmdlet.

How to Use the Where-Object in PowerShell to Filter Everything

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’}

Get-VM -VMName HYPER_old | Where-Object {$_.State -eq ‘Running’}

Get-VM output filtering out the VMs in the Running stateGet-VM output filtering out the VMs in the Running state

Starting and stopping virtual machines

The VM that was generated previously is most likely shut down at this point. Let’s fix that by getting it started and then learning how to halt virtual machines.

In the PowerShell session on the remote Hyper-V host:

1. Use the -Name option to provide the Start-VM cmdlet the name (Name) of the VM you built previously.

The Start-VM command starts the HYPER old VM.The Start-VM command starts the HYPER old VM.

After the VM has been launched, use the Stop-VM cmdlet to stop it by passing the Name argument the VM’s name.

The VM will shut down as soon as you issue the command above, as seen in the picture below.

The HYPER old VM is being stopped by Stop-VM.The HYPER old VM is being stopped by Stop-VM.

Changing Hyper-V virtual machines

Virtual machines (VMs) do not always behave in the same manner. Perhaps the CPU resources need to be increased, or the VM is always running out of memory. In this scenario, the Set-VM cmdlet comes in handy.

As an example of modifying existing VMs, In the PowerShell session on the remote Hyper-V host:

To automatically stop the HYPER old VM that is presently operating, use the Set-VM cmdlet. To guarantee that the VM is correctly shut down when the Hyper-V host is shut down, use the Name parameter to identify the VM you wish to define and the AutomaticStopAction parameter to provide Shutdown as the value.

Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name

Hyper-V virtual machines may be saved.

You may need to save the VM you create in the remote Hyper-V host’s PowerShell session to save the VM’s memory state for later usage. Use the Save-VM cmdlet with the Name argument set to the name of the virtual machine you wish to save.

It’s important to note that the VM you wish to preserve must be running.

The Save-VM cmdlet saves the state of the HYPER old virtual machine.The Save-VM cmdlet saves the state of the HYPER old virtual machine.

Managing VM Checkpoints in Hyper-V

You should learn about checkpoints if you need to store the current state of a VM before making changes or rollback VM modifications. Checkpoints are a convenient method to rapidly store a Hyper-V VM’s disk and memory state.

Run the Checkpoint-VM cmdlet on your Hyper-V host, passing in the name of the VM to save and a checkpoint name.

SnapshotName is a parameter name that still refers to Hyper-V 2012 nomenclature. A checkpoint is the same as a snapshot.

HYPER old -SnapshotName Checkpoint-VM MyVMSnapshot

Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.

After you’ve made a checkpoint, you can use the Get-VMSnapshot cmdlet to get a list of all the snapshots on the Hyper-V host. The VM HYPER old contains three checkpoints, as you can see below.

HYPER old -VMName Get-VMSnapshot

Gets all of the Snapshots for the HYPER old VM.Gets all of the Snapshots for the HYPER old VM.

Conclusion

You’re well on your way to controlling Hyper-V VMs using PowerShell if you’ve completed all of the examples in this tutorial. You should now be able to manage 1, 10, or even 100 virtual machines!

What kinds of jobs do you believe PowerShell and Hyper-V can now automate?

.State -eq ‘Running’ | Get-VM -VMName HYPER old

Get-VM -VMName HYPER_old | Where-Object {$_.State -eq ‘Running’}

Get-VM output filtering out the VMs in the Running stateGet-VM output filtering out the VMs in the Running state

Starting and stopping virtual machines

The VM that was generated previously is most likely shut down at this point. Let’s fix that by getting it started and then learning how to halt virtual machines.

In the PowerShell session on the remote Hyper-V host:

1. Use the -Name option to provide the Start-VM cmdlet the name (Name) of the VM you built previously.

The Start-VM command starts the HYPER old VM.The Start-VM command starts the HYPER old VM.

After the VM has been launched, use the Stop-VM cmdlet to stop it by passing the Name argument the VM’s name.

The VM will shut down as soon as you issue the command above, as seen in the picture below.

The HYPER old VM is being stopped by Stop-VM.The HYPER old VM is being stopped by Stop-VM.

Changing Hyper-V virtual machines

Virtual machines (VMs) do not always behave in the same manner. Perhaps the CPU resources need to be increased, or the VM is always running out of memory. In this scenario, the Set-VM cmdlet comes in handy.

As an example of modifying existing VMs, In the PowerShell session on the remote Hyper-V host:

To automatically stop the HYPER old VM that is presently operating, use the Set-VM cmdlet. To guarantee that the VM is correctly shut down when the Hyper-V host is shut down, use the Name parameter to identify the VM you wish to define and the AutomaticStopAction parameter to provide Shutdown as the value.

Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name

Hyper-V virtual machines may be saved.

You may need to save the VM you create in the remote Hyper-V host’s PowerShell session to save the VM’s memory state for later usage. Use the Save-VM cmdlet with the Name argument set to the name of the virtual machine you wish to save.

It’s important to note that the VM you wish to preserve must be running.

The Save-VM cmdlet saves the state of the HYPER old virtual machine.The Save-VM cmdlet saves the state of the HYPER old virtual machine.

Managing VM Checkpoints in Hyper-V

You should learn about checkpoints if you need to store the current state of a VM before making changes or rollback VM modifications. Checkpoints are a convenient method to rapidly store a Hyper-V VM’s disk and memory state.

Run the Checkpoint-VM cmdlet on your Hyper-V host, passing in the name of the VM to save and a checkpoint name.

SnapshotName is a parameter name that still refers to Hyper-V 2012 nomenclature. A checkpoint is the same as a snapshot.

HYPER old -SnapshotName Checkpoint-VM MyVMSnapshot

Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.

After you’ve made a checkpoint, you can use the Get-VMSnapshot cmdlet to get a list of all the snapshots on the Hyper-V host. The VM HYPER old contains three checkpoints, as you can see below.

HYPER old -VMName Get-VMSnapshot

Gets all of the Snapshots for the HYPER old VM.Gets all of the Snapshots for the HYPER old VM.

Conclusion

You’re well on your way to controlling Hyper-V VMs using PowerShell if you’ve completed all of the examples in this tutorial. You should now be able to manage 1, 10, or even 100 virtual machines!

What kinds of jobs do you believe PowerShell and Hyper-V can now automate?

.State -eq ‘Running’ | Get-VM -VMName HYPER old

Where-Object

You’re undoubtedly acquainted with the Hyper-V Manager if you use Microsoft’s Hyper-V virtualization framework to operate virtual machines. But did you know that the Hyper-V PowerShell module may help you get more done in less time?

You’ll learn how to manage Hyper-V VMs using PowerShell in this article, including how to create, remove, and manage VM snapshots!

How to Manage Hyper-V Hosts from a Windows Non-Domain Client

Prerequisites

You’ll need the following items to complete this tutorial:

  • A Windows client for connecting to a Hyper-V host from afar. The operating system used in this lesson is Windows 10 Pro.
  • PowerShell Remoting is enabled on a Hyper-V host. The Hyper-V host in this lesson is called HYPER and is part of a workgroup, although an Active-Directory linked client and host will also function.
  • A user account in the local administrators group or the Hyper-V Administrators group on the Hyper-V server. This tutorial will make use of the account localadmin.

Connecting to a Hyper-V Host from afar

To use PowerShell with Hyper-V, you must be able to interface with the Hyper-V host in some way. You may accomplish this locally by using the Hyper-V PowerShell cmdlets and specifying the Hyper-V host’s name, or you can use PowerShell Remoting to connect to the Hyper-V server.

You will establish a persistent connection to the Hyper-V host and conduct the instructions on the Hyper-V server itself in this tutorial.

Related: [Step-by-Step] How to Set Up PSRemoting with WinRM and SSL

1. On your local computer, launch PowerShell.

2. Run the Enter-PSSession cmdlet with the ComputerName option set to the hostname of your remote Hyper-V machine. This operation initiates an interactive session, allowing you to perform commands on the remote Hyper-V server interactively.

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

You don’t need to utilize the Credential argument if your client and Hyper-V host are both members of the same Active Directory domain.

3. To connect to the Hyper-V host, you’ll be asked for a username and password. On the remote computer, this username and password will be for a local administrator account. When you’re connected, your PowerShell prompt should update to indicate the Hyper-V host’s hostname.

You’re all set to begin executing commands!

Using PowerShell to create Hyper-V VMs

Let’s start executing commands by constructing a Hyper-V VM, assuming you’re now connected to your Hyper-V host using PowerShell Remoting.

Creating a Basic Virtual Machine

While connected to the remote Hyper-V host using PSRemoting:

To build a new VM, use the New-VM cmdlet. When using the New-VM cmdlet to build a virtual machine, you have a variety of choices to pick from.

1. In the following example, the instruction is constructing a virtual machine with:

  • MyVM’s moniker (HYPER)
  • 512 megabytes of RAM (MemoryStartupBytes)

-MemoryStartupBytes 512MB -New-VM -Name “HYPER”

New VM named "HYPER"“HYPER” is a new virtual machine.

Creating a Virtual Machine Using Other VM Attributes

You may need to construct a VM with properties that are comparable to those of another VM. You may accomplish that by assigning different VM properties to variables, which you can then utilize to create the new VM. Consider the following scenario:

1. Use Get-VM to query the properties of an existing virtual machine and save the results to a variable, as shown below.

Get-VM “HYPER old” $VMold = Get-VM “HYPER old”

2. Run the Get-VMMemory cmdlet with the name of the VM you want to collect characteristics from (in this example, memory) and set the memory value to a variable.

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

3. Next, use the New-VM cmdlet to create a new VM with the Name, VM generation (Generation) from the other VM’s Generation property, and amount of RAM from the other VM’s value.

$VMold.Generation -MemoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memory

An old VM was used to build a new one.An old VM was used to build a new one.

Using PowerShell to list existing VMs

Let’s look at how to enumerate generated VMs now that you’ve built at least two on the Hyper-V host. To do so, follow these steps:

1. Simply run the Get-VM cmdlet. Get-VM searches the Hyper-V host for all existing VMs when called without arguments. Get-VM

Get-VM output when performed without parametersGet-VM output when performed without parameters

2. Perhaps you simply want to seek for a single virtual machine. Use the -Name argument in such scenario. The code below searches Hyper-V for the VM called HYPER old that was built before. Get-VM HYPER old -Name

Get-VM output using the -Name parameter.Get-VM output using the -Name parameter.

Following that, you may need to locate all VMs that are in a given State. It’s no issue. Run Get-VM, which will query all VMs and send the results to the Where-Object cmdlet.

How to Use the Where-Object in PowerShell to Filter Everything

The Pipe ‘|’ in the example below restricts Get-output VM’s to to those VM objects that have a State of Running. Where-Object

You’re undoubtedly acquainted with the Hyper-V Manager if you use Microsoft’s Hyper-V virtualization framework to operate virtual machines. But did you know that the Hyper-V PowerShell module may help you get more done in less time?

You’ll learn how to manage Hyper-V VMs using PowerShell in this article, including how to create, remove, and manage VM snapshots!

How to Manage Hyper-V Hosts from a Windows Non-Domain Client

Prerequisites

You’ll need the following items to complete this tutorial:

  • A Windows client for connecting to a Hyper-V host from afar. The operating system used in this lesson is Windows 10 Pro.
  • PowerShell Remoting is enabled on a Hyper-V host. The Hyper-V host in this lesson is called HYPER and is part of a workgroup, although an Active-Directory linked client and host will also function.
  • A user account in the local administrators group or the Hyper-V Administrators group on the Hyper-V server. This tutorial will make use of the account localadmin.

Connecting to a Hyper-V Host from afar

To use PowerShell with Hyper-V, you must be able to interface with the Hyper-V host in some way. You may accomplish this locally by using the Hyper-V PowerShell cmdlets and specifying the Hyper-V host’s name, or you can use PowerShell Remoting to connect to the Hyper-V server.

You will establish a persistent connection to the Hyper-V host and conduct the instructions on the Hyper-V server itself in this tutorial.

Related: [Step-by-Step] How to Set Up PSRemoting with WinRM and SSL

1. On your local computer, launch PowerShell.

2. Run the Enter-PSSession cmdlet with the ComputerName option set to the hostname of your remote Hyper-V machine. This operation initiates an interactive session, allowing you to perform commands on the remote Hyper-V server interactively.

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

You don’t need to utilize the Credential argument if your client and Hyper-V host are both members of the same Active Directory domain.

3. To connect to the Hyper-V host, you’ll be asked for a username and password. On the remote computer, this username and password will be for a local administrator account. When you’re connected, your PowerShell prompt should update to indicate the Hyper-V host’s hostname.

You’re all set to begin executing commands!

Using PowerShell to create Hyper-V VMs

Let’s start executing commands by constructing a Hyper-V VM, assuming you’re now connected to your Hyper-V host using PowerShell Remoting.

Creating a Basic Virtual Machine

While connected to the remote Hyper-V host using PSRemoting:

To build a new VM, use the New-VM cmdlet. When using the New-VM cmdlet to build a virtual machine, you have a variety of choices to pick from.

1. In the following example, the instruction is constructing a virtual machine with:

  • MyVM’s moniker (HYPER)
  • 512 megabytes of RAM (MemoryStartupBytes)

-MemoryStartupBytes 512MB -New-VM -Name “HYPER”

New VM named "HYPER"“HYPER” is a new virtual machine.

Creating a Virtual Machine Using Other VM Attributes

You may need to construct a VM with properties that are comparable to those of another VM. You may accomplish that by assigning different VM properties to variables, which you can then utilize to create the new VM. Consider the following scenario:

1. Use Get-VM to query the properties of an existing virtual machine and save the results to a variable, as shown below.

Get-VM “HYPER old” $VMold = Get-VM “HYPER old”

2. Run the Get-VMMemory cmdlet with the name of the VM you want to collect characteristics from (in this example, memory) and set the memory value to a variable.

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

3. Next, use the New-VM cmdlet to create a new VM with the Name, VM generation (Generation) from the other VM’s Generation property, and amount of RAM from the other VM’s value.

$VMold.Generation -MemoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memory

An old VM was used to build a new one.An old VM was used to build a new one.

Using PowerShell to list existing VMs

Let’s look at how to enumerate generated VMs now that you’ve built at least two on the Hyper-V host. To do so, follow these steps:

1. Simply run the Get-VM cmdlet. Get-VM searches the Hyper-V host for all existing VMs when called without arguments. Get-VM

Get-VM output when performed without parametersGet-VM output when performed without parameters

2. Perhaps you simply want to seek for a single virtual machine. Use the -Name argument in such scenario. The code below searches Hyper-V for the VM called HYPER old that was built before. Get-VM HYPER old -Name

Get-VM output using the -Name parameter.Get-VM output using the -Name parameter.

Following that, you may need to locate all VMs that are in a given State. It’s no issue. Run Get-VM, which will query all VMs and send the results to the Where-Object cmdlet.

How to Use the Where-Object in PowerShell to Filter Everything

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’}

Get-VM -VMName HYPER_old | Where-Object {$_.State -eq ‘Running’}

Get-VM output filtering out the VMs in the Running stateGet-VM output filtering out the VMs in the Running state

Starting and stopping virtual machines

The VM that was generated previously is most likely shut down at this point. Let’s fix that by getting it started and then learning how to halt virtual machines.

In the PowerShell session on the remote Hyper-V host:

1. Use the -Name option to provide the Start-VM cmdlet the name (Name) of the VM you built previously.

The Start-VM command starts the HYPER old VM.The Start-VM command starts the HYPER old VM.

After the VM has been launched, use the Stop-VM cmdlet to stop it by passing the Name argument the VM’s name.

The VM will shut down as soon as you issue the command above, as seen in the picture below.

The HYPER old VM is being stopped by Stop-VM.The HYPER old VM is being stopped by Stop-VM.

Changing Hyper-V virtual machines

Virtual machines (VMs) do not always behave in the same manner. Perhaps the CPU resources need to be increased, or the VM is always running out of memory. In this scenario, the Set-VM cmdlet comes in handy.

As an example of modifying existing VMs, In the PowerShell session on the remote Hyper-V host:

To automatically stop the HYPER old VM that is presently operating, use the Set-VM cmdlet. To guarantee that the VM is correctly shut down when the Hyper-V host is shut down, use the Name parameter to identify the VM you wish to define and the AutomaticStopAction parameter to provide Shutdown as the value.

Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name

Hyper-V virtual machines may be saved.

You may need to save the VM you create in the remote Hyper-V host’s PowerShell session to save the VM’s memory state for later usage. Use the Save-VM cmdlet with the Name argument set to the name of the virtual machine you wish to save.

It’s important to note that the VM you wish to preserve must be running.

The Save-VM cmdlet saves the state of the HYPER old virtual machine.The Save-VM cmdlet saves the state of the HYPER old virtual machine.

Managing VM Checkpoints in Hyper-V

You should learn about checkpoints if you need to store the current state of a VM before making changes or rollback VM modifications. Checkpoints are a convenient method to rapidly store a Hyper-V VM’s disk and memory state.

Run the Checkpoint-VM cmdlet on your Hyper-V host, passing in the name of the VM to save and a checkpoint name.

SnapshotName is a parameter name that still refers to Hyper-V 2012 nomenclature. A checkpoint is the same as a snapshot.

HYPER old -SnapshotName Checkpoint-VM MyVMSnapshot

Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.

After you’ve made a checkpoint, you can use the Get-VMSnapshot cmdlet to get a list of all the snapshots on the Hyper-V host. The VM HYPER old contains three checkpoints, as you can see below.

HYPER old -VMName Get-VMSnapshot

Gets all of the Snapshots for the HYPER old VM.Gets all of the Snapshots for the HYPER old VM.

Conclusion

You’re well on your way to controlling Hyper-V VMs using PowerShell if you’ve completed all of the examples in this tutorial. You should now be able to manage 1, 10, or even 100 virtual machines!

What kinds of jobs do you believe PowerShell and Hyper-V can now automate?

.State -eq ‘Running’ | Get-VM -VMName HYPER old

Get-VM -VMName HYPER_old | Where-Object {$_.State -eq ‘Running’}

Get-VM output filtering out the VMs in the Running stateGet-VM output filtering out the VMs in the Running state

Starting and stopping virtual machines

The VM that was generated previously is most likely shut down at this point. Let’s fix that by getting it started and then learning how to halt virtual machines.

In the PowerShell session on the remote Hyper-V host:

1. Use the -Name option to provide the Start-VM cmdlet the name (Name) of the VM you built previously.

The Start-VM command starts the HYPER old VM.The Start-VM command starts the HYPER old VM.

After the VM has been launched, use the Stop-VM cmdlet to stop it by passing the Name argument the VM’s name.

The VM will shut down as soon as you issue the command above, as seen in the picture below.

The HYPER old VM is being stopped by Stop-VM.The HYPER old VM is being stopped by Stop-VM.

Changing Hyper-V virtual machines

Virtual machines (VMs) do not always behave in the same manner. Perhaps the CPU resources need to be increased, or the VM is always running out of memory. In this scenario, the Set-VM cmdlet comes in handy.

As an example of modifying existing VMs, In the PowerShell session on the remote Hyper-V host:

To automatically stop the HYPER old VM that is presently operating, use the Set-VM cmdlet. To guarantee that the VM is correctly shut down when the Hyper-V host is shut down, use the Name parameter to identify the VM you wish to define and the AutomaticStopAction parameter to provide Shutdown as the value.

Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name

Hyper-V virtual machines may be saved.

You may need to save the VM you create in the remote Hyper-V host’s PowerShell session to save the VM’s memory state for later usage. Use the Save-VM cmdlet with the Name argument set to the name of the virtual machine you wish to save.

It’s important to note that the VM you wish to preserve must be running.

The Save-VM cmdlet saves the state of the HYPER old virtual machine.The Save-VM cmdlet saves the state of the HYPER old virtual machine.

Managing VM Checkpoints in Hyper-V

You should learn about checkpoints if you need to store the current state of a VM before making changes or rollback VM modifications. Checkpoints are a convenient method to rapidly store a Hyper-V VM’s disk and memory state.

Run the Checkpoint-VM cmdlet on your Hyper-V host, passing in the name of the VM to save and a checkpoint name.

SnapshotName is a parameter name that still refers to Hyper-V 2012 nomenclature. A checkpoint is the same as a snapshot.

HYPER old -SnapshotName Checkpoint-VM MyVMSnapshot

Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.

After you’ve made a checkpoint, you can use the Get-VMSnapshot cmdlet to get a list of all the snapshots on the Hyper-V host. The VM HYPER old contains three checkpoints, as you can see below.

HYPER old -VMName Get-VMSnapshot

Gets all of the Snapshots for the HYPER old VM.Gets all of the Snapshots for the HYPER old VM.

Conclusion

You’re well on your way to controlling Hyper-V VMs using PowerShell if you’ve completed all of the examples in this tutorial. You should now be able to manage 1, 10, or even 100 virtual machines!

What kinds of jobs do you believe PowerShell and Hyper-V can now automate?

.State -eq ‘Running’ | Get-VM -VMName HYPER old

Get-VM output filtering out the VMs in the Running stateGet-VM output filtering out the VMs in the Running state

Starting and stopping virtual machines

The VM that was generated previously is most likely shut down at this point. Let’s fix that by getting it started and then learning how to halt virtual machines.

In the PowerShell session on the remote Hyper-V host:

1. Use the -Name option to provide the Start-VM cmdlet the name (Name) of the VM you built previously.

The Start-VM command starts the HYPER old VM.The Start-VM command starts the HYPER old VM.

After the VM has been launched, use the Stop-VM cmdlet to stop it by passing the Name argument the VM’s name.

The VM will shut down as soon as you issue the command above, as seen in the picture below.

The HYPER old VM is being stopped by Stop-VM.The HYPER old VM is being stopped by Stop-VM.

Changing Hyper-V virtual machines

Virtual machines (VMs) do not always behave in the same manner. Perhaps the CPU resources need to be increased, or the VM is always running out of memory. In this scenario, the Set-VM cmdlet comes in handy.

As an example of modifying existing VMs, In the PowerShell session on the remote Hyper-V host:

To automatically stop the HYPER old VM that is presently operating, use the Set-VM cmdlet. To guarantee that the VM is correctly shut down when the Hyper-V host is shut down, use the Name parameter to identify the VM you wish to define and the AutomaticStopAction parameter to provide Shutdown as the value.

Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name

Hyper-V virtual machines may be saved.

You may need to save the VM you create in the remote Hyper-V host’s PowerShell session to save the VM’s memory state for later usage. Use the Save-VM cmdlet with the Name argument set to the name of the virtual machine you wish to save.

It’s important to note that the VM you wish to preserve must be running.

The Save-VM cmdlet saves the state of the HYPER old virtual machine.The Save-VM cmdlet saves the state of the HYPER old virtual machine.

Managing VM Checkpoints in Hyper-V

You should learn about checkpoints if you need to store the current state of a VM before making changes or rollback VM modifications. Checkpoints are a convenient method to rapidly store a Hyper-V VM’s disk and memory state.

Run the Checkpoint-VM cmdlet on your Hyper-V host, passing in the name of the VM to save and a checkpoint name.

SnapshotName is a parameter name that still refers to Hyper-V 2012 nomenclature. A checkpoint is the same as a snapshot.

HYPER old -SnapshotName Checkpoint-VM MyVMSnapshot

Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.

After you’ve made a checkpoint, you can use the Get-VMSnapshot cmdlet to get a list of all the snapshots on the Hyper-V host. The VM HYPER old contains three checkpoints, as you can see below.

HYPER old -VMName Get-VMSnapshot

Gets all of the Snapshots for the HYPER old VM.Gets all of the Snapshots for the HYPER old VM.

Conclusion

You’re well on your way to controlling Hyper-V VMs using PowerShell if you’ve completed all of the examples in this tutorial. You should now be able to manage 1, 10, or even 100 virtual machines!

What kinds of jobs do you believe PowerShell and Hyper-V can now automate?

.State -eq ‘Running’ | Get-VM -VMName HYPER old

Where-Object

You’re undoubtedly acquainted with the Hyper-V Manager if you use Microsoft’s Hyper-V virtualization framework to operate virtual machines. But did you know that the Hyper-V PowerShell module may help you get more done in less time?

You’ll learn how to manage Hyper-V VMs using PowerShell in this article, including how to create, remove, and manage VM snapshots!

How to Manage Hyper-V Hosts from a Windows Non-Domain Client

Prerequisites

You’ll need the following items to complete this tutorial:

  • A Windows client for connecting to a Hyper-V host from afar. The operating system used in this lesson is Windows 10 Pro.
  • PowerShell Remoting is enabled on a Hyper-V host. The Hyper-V host in this lesson is called HYPER and is part of a workgroup, although an Active-Directory linked client and host will also function.
  • A user account in the local administrators group or the Hyper-V Administrators group on the Hyper-V server. This tutorial will make use of the account localadmin.

Connecting to a Hyper-V Host from afar

To use PowerShell with Hyper-V, you must be able to interface with the Hyper-V host in some way. You may accomplish this locally by using the Hyper-V PowerShell cmdlets and specifying the Hyper-V host’s name, or you can use PowerShell Remoting to connect to the Hyper-V server.

You will establish a persistent connection to the Hyper-V host and conduct the instructions on the Hyper-V server itself in this tutorial.

Related: [Step-by-Step] How to Set Up PSRemoting with WinRM and SSL

1. On your local computer, launch PowerShell.

2. Run the Enter-PSSession cmdlet with the ComputerName option set to the hostname of your remote Hyper-V machine. This operation initiates an interactive session, allowing you to perform commands on the remote Hyper-V server interactively.

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

You don’t need to utilize the Credential argument if your client and Hyper-V host are both members of the same Active Directory domain.

3. To connect to the Hyper-V host, you’ll be asked for a username and password. On the remote computer, this username and password will be for a local administrator account. When you’re connected, your PowerShell prompt should update to indicate the Hyper-V host’s hostname.

You’re all set to begin executing commands!

Using PowerShell to create Hyper-V VMs

Let’s start executing commands by constructing a Hyper-V VM, assuming you’re now connected to your Hyper-V host using PowerShell Remoting.

Creating a Basic Virtual Machine

While connected to the remote Hyper-V host using PSRemoting:

To build a new VM, use the New-VM cmdlet. When using the New-VM cmdlet to build a virtual machine, you have a variety of choices to pick from.

1. In the following example, the instruction is constructing a virtual machine with:

  • MyVM’s moniker (HYPER)
  • 512 megabytes of RAM (MemoryStartupBytes)

-MemoryStartupBytes 512MB -New-VM -Name “HYPER”

New VM named "HYPER"“HYPER” is a new virtual machine.

Creating a Virtual Machine Using Other VM Attributes

You may need to construct a VM with properties that are comparable to those of another VM. You may accomplish that by assigning different VM properties to variables, which you can then utilize to create the new VM. Consider the following scenario:

1. Use Get-VM to query the properties of an existing virtual machine and save the results to a variable, as shown below.

Get-VM “HYPER old” $VMold = Get-VM “HYPER old”

2. Run the Get-VMMemory cmdlet with the name of the VM you want to collect characteristics from (in this example, memory) and set the memory value to a variable.

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

3. Next, use the New-VM cmdlet to create a new VM with the Name, VM generation (Generation) from the other VM’s Generation property, and amount of RAM from the other VM’s value.

$VMold.Generation -MemoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memory

An old VM was used to build a new one.An old VM was used to build a new one.

Using PowerShell to list existing VMs

Let’s look at how to enumerate generated VMs now that you’ve built at least two on the Hyper-V host. To do so, follow these steps:

1. Simply run the Get-VM cmdlet. Get-VM searches the Hyper-V host for all existing VMs when called without arguments. Get-VM

Get-VM output when performed without parametersGet-VM output when performed without parameters

2. Perhaps you simply want to seek for a single virtual machine. Use the -Name argument in such scenario. The code below searches Hyper-V for the VM called HYPER old that was built before. Get-VM HYPER old -Name

Get-VM output using the -Name parameter.Get-VM output using the -Name parameter.

Following that, you may need to locate all VMs that are in a given State. It’s no issue. Run Get-VM, which will query all VMs and send the results to the Where-Object cmdlet.

How to Use the Where-Object in PowerShell to Filter Everything

The Pipe ‘|’ in the example below restricts Get-output VM’s to to those VM objects that have a State of Running. Where-Object

You’re undoubtedly acquainted with the Hyper-V Manager if you use Microsoft’s Hyper-V virtualization framework to operate virtual machines. But did you know that the Hyper-V PowerShell module may help you get more done in less time?

You’ll learn how to manage Hyper-V VMs using PowerShell in this article, including how to create, remove, and manage VM snapshots!

How to Manage Hyper-V Hosts from a Windows Non-Domain Client

Prerequisites

You’ll need the following items to complete this tutorial:

  • A Windows client for connecting to a Hyper-V host from afar. The operating system used in this lesson is Windows 10 Pro.
  • PowerShell Remoting is enabled on a Hyper-V host. The Hyper-V host in this lesson is called HYPER and is part of a workgroup, although an Active-Directory linked client and host will also function.
  • A user account in the local administrators group or the Hyper-V Administrators group on the Hyper-V server. This tutorial will make use of the account localadmin.

Connecting to a Hyper-V Host from afar

To use PowerShell with Hyper-V, you must be able to interface with the Hyper-V host in some way. You may accomplish this locally by using the Hyper-V PowerShell cmdlets and specifying the Hyper-V host’s name, or you can use PowerShell Remoting to connect to the Hyper-V server.

You will establish a persistent connection to the Hyper-V host and conduct the instructions on the Hyper-V server itself in this tutorial.

Related: [Step-by-Step] How to Set Up PSRemoting with WinRM and SSL

1. On your local computer, launch PowerShell.

2. Run the Enter-PSSession cmdlet with the ComputerName option set to the hostname of your remote Hyper-V machine. This operation initiates an interactive session, allowing you to perform commands on the remote Hyper-V server interactively.

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

You don’t need to utilize the Credential argument if your client and Hyper-V host are both members of the same Active Directory domain.

3. To connect to the Hyper-V host, you’ll be asked for a username and password. On the remote computer, this username and password will be for a local administrator account. When you’re connected, your PowerShell prompt should update to indicate the Hyper-V host’s hostname.

You’re all set to begin executing commands!

Using PowerShell to create Hyper-V VMs

Let’s start executing commands by constructing a Hyper-V VM, assuming you’re now connected to your Hyper-V host using PowerShell Remoting.

Creating a Basic Virtual Machine

While connected to the remote Hyper-V host using PSRemoting:

To build a new VM, use the New-VM cmdlet. When using the New-VM cmdlet to build a virtual machine, you have a variety of choices to pick from.

1. In the following example, the instruction is constructing a virtual machine with:

  • MyVM’s moniker (HYPER)
  • 512 megabytes of RAM (MemoryStartupBytes)

-MemoryStartupBytes 512MB -New-VM -Name “HYPER”

New VM named "HYPER"“HYPER” is a new virtual machine.

Creating a Virtual Machine Using Other VM Attributes

You may need to construct a VM with properties that are comparable to those of another VM. You may accomplish that by assigning different VM properties to variables, which you can then utilize to create the new VM. Consider the following scenario:

1. Use Get-VM to query the properties of an existing virtual machine and save the results to a variable, as shown below.

Get-VM “HYPER old” $VMold = Get-VM “HYPER old”

2. Run the Get-VMMemory cmdlet with the name of the VM you want to collect characteristics from (in this example, memory) and set the memory value to a variable.

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

3. Next, use the New-VM cmdlet to create a new VM with the Name, VM generation (Generation) from the other VM’s Generation property, and amount of RAM from the other VM’s value.

$VMold.Generation -MemoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memoryStartupBytes $memory

An old VM was used to build a new one.An old VM was used to build a new one.

Using PowerShell to list existing VMs

Let’s look at how to enumerate generated VMs now that you’ve built at least two on the Hyper-V host. To do so, follow these steps:

1. Simply run the Get-VM cmdlet. Get-VM searches the Hyper-V host for all existing VMs when called without arguments. Get-VM

Get-VM output when performed without parametersGet-VM output when performed without parameters

2. Perhaps you simply want to seek for a single virtual machine. Use the -Name argument in such scenario. The code below searches Hyper-V for the VM called HYPER old that was built before. Get-VM HYPER old -Name

Get-VM output using the -Name parameter.Get-VM output using the -Name parameter.

Following that, you may need to locate all VMs that are in a given State. It’s no issue. Run Get-VM, which will query all VMs and send the results to the Where-Object cmdlet.

How to Use the Where-Object in PowerShell to Filter Everything

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’}

Get-VM -VMName HYPER_old | Where-Object {$_.State -eq ‘Running’}

Get-VM output filtering out the VMs in the Running stateGet-VM output filtering out the VMs in the Running state

Starting and stopping virtual machines

The VM that was generated previously is most likely shut down at this point. Let’s fix that by getting it started and then learning how to halt virtual machines.

In the PowerShell session on the remote Hyper-V host:

1. Use the -Name option to provide the Start-VM cmdlet the name (Name) of the VM you built previously.

The Start-VM command starts the HYPER old VM.The Start-VM command starts the HYPER old VM.

After the VM has been launched, use the Stop-VM cmdlet to stop it by passing the Name argument the VM’s name.

The VM will shut down as soon as you issue the command above, as seen in the picture below.

The HYPER old VM is being stopped by Stop-VM.The HYPER old VM is being stopped by Stop-VM.

Changing Hyper-V virtual machines

Virtual machines (VMs) do not always behave in the same manner. Perhaps the CPU resources need to be increased, or the VM is always running out of memory. In this scenario, the Set-VM cmdlet comes in handy.

As an example of modifying existing VMs, In the PowerShell session on the remote Hyper-V host:

To automatically stop the HYPER old VM that is presently operating, use the Set-VM cmdlet. To guarantee that the VM is correctly shut down when the Hyper-V host is shut down, use the Name parameter to identify the VM you wish to define and the AutomaticStopAction parameter to provide Shutdown as the value.

Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name

Hyper-V virtual machines may be saved.

You may need to save the VM you create in the remote Hyper-V host’s PowerShell session to save the VM’s memory state for later usage. Use the Save-VM cmdlet with the Name argument set to the name of the virtual machine you wish to save.

It’s important to note that the VM you wish to preserve must be running.

The Save-VM cmdlet saves the state of the HYPER old virtual machine.The Save-VM cmdlet saves the state of the HYPER old virtual machine.

Managing VM Checkpoints in Hyper-V

You should learn about checkpoints if you need to store the current state of a VM before making changes or rollback VM modifications. Checkpoints are a convenient method to rapidly store a Hyper-V VM’s disk and memory state.

Run the Checkpoint-VM cmdlet on your Hyper-V host, passing in the name of the VM to save and a checkpoint name.

SnapshotName is a parameter name that still refers to Hyper-V 2012 nomenclature. A checkpoint is the same as a snapshot.

HYPER old -SnapshotName Checkpoint-VM MyVMSnapshot

Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.

After you’ve made a checkpoint, you can use the Get-VMSnapshot cmdlet to get a list of all the snapshots on the Hyper-V host. The VM HYPER old contains three checkpoints, as you can see below.

HYPER old -VMName Get-VMSnapshot

Gets all of the Snapshots for the HYPER old VM.Gets all of the Snapshots for the HYPER old VM.

Conclusion

You’re well on your way to controlling Hyper-V VMs using PowerShell if you’ve completed all of the examples in this tutorial. You should now be able to manage 1, 10, or even 100 virtual machines!

What kinds of jobs do you believe PowerShell and Hyper-V can now automate?

.State -eq ‘Running’ | Get-VM -VMName HYPER old

Get-VM -VMName HYPER_old | Where-Object {$_.State -eq ‘Running’}

Get-VM output filtering out the VMs in the Running stateGet-VM output filtering out the VMs in the Running state

Starting and stopping virtual machines

The VM that was generated previously is most likely shut down at this point. Let’s fix that by getting it started and then learning how to halt virtual machines.

In the PowerShell session on the remote Hyper-V host:

1. Use the -Name option to provide the Start-VM cmdlet the name (Name) of the VM you built previously.

The Start-VM command starts the HYPER old VM.The Start-VM command starts the HYPER old VM.

After the VM has been launched, use the Stop-VM cmdlet to stop it by passing the Name argument the VM’s name.

The VM will shut down as soon as you issue the command above, as seen in the picture below.

The HYPER old VM is being stopped by Stop-VM.The HYPER old VM is being stopped by Stop-VM.

Changing Hyper-V virtual machines

Virtual machines (VMs) do not always behave in the same manner. Perhaps the CPU resources need to be increased, or the VM is always running out of memory. In this scenario, the Set-VM cmdlet comes in handy.

As an example of modifying existing VMs, In the PowerShell session on the remote Hyper-V host:

To automatically stop the HYPER old VM that is presently operating, use the Set-VM cmdlet. To guarantee that the VM is correctly shut down when the Hyper-V host is shut down, use the Name parameter to identify the VM you wish to define and the AutomaticStopAction parameter to provide Shutdown as the value.

Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name

Hyper-V virtual machines may be saved.

You may need to save the VM you create in the remote Hyper-V host’s PowerShell session to save the VM’s memory state for later usage. Use the Save-VM cmdlet with the Name argument set to the name of the virtual machine you wish to save.

It’s important to note that the VM you wish to preserve must be running.

The Save-VM cmdlet saves the state of the HYPER old virtual machine.The Save-VM cmdlet saves the state of the HYPER old virtual machine.

Managing VM Checkpoints in Hyper-V

You should learn about checkpoints if you need to store the current state of a VM before making changes or rollback VM modifications. Checkpoints are a convenient method to rapidly store a Hyper-V VM’s disk and memory state.

Run the Checkpoint-VM cmdlet on your Hyper-V host, passing in the name of the VM to save and a checkpoint name.

SnapshotName is a parameter name that still refers to Hyper-V 2012 nomenclature. A checkpoint is the same as a snapshot.

HYPER old -SnapshotName Checkpoint-VM MyVMSnapshot

Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.

After you’ve made a checkpoint, you can use the Get-VMSnapshot cmdlet to get a list of all the snapshots on the Hyper-V host. The VM HYPER old contains three checkpoints, as you can see below.

HYPER old -VMName Get-VMSnapshot

Gets all of the Snapshots for the HYPER old VM.Gets all of the Snapshots for the HYPER old VM.

Conclusion

You’re well on your way to controlling Hyper-V VMs using PowerShell if you’ve completed all of the examples in this tutorial. You should now be able to manage 1, 10, or even 100 virtual machines!

What kinds of jobs do you believe PowerShell and Hyper-V can now automate?

.State -eq ‘Running’ | Get-VM -VMName HYPER old

Get-VM output filtering out the VMs in the Running stateGet-VM output filtering out the VMs in the Running state

Starting and stopping virtual machines

The VM that was generated previously is most likely shut down at this point. Let’s fix that by getting it started and then learning how to halt virtual machines.

In the PowerShell session on the remote Hyper-V host:

1. Use the -Name option to provide the Start-VM cmdlet the name (Name) of the VM you built previously.

The Start-VM command starts the HYPER old VM.The Start-VM command starts the HYPER old VM.

After the VM has been launched, use the Stop-VM cmdlet to stop it by passing the Name argument the VM’s name.

The VM will shut down as soon as you issue the command above, as seen in the picture below.

The HYPER old VM is being stopped by Stop-VM.The HYPER old VM is being stopped by Stop-VM.

Changing Hyper-V virtual machines

Virtual machines (VMs) do not always behave in the same manner. Perhaps the CPU resources need to be increased, or the VM is always running out of memory. In this scenario, the Set-VM cmdlet comes in handy.

As an example of modifying existing VMs, In the PowerShell session on the remote Hyper-V host:

To automatically stop the HYPER old VM that is presently operating, use the Set-VM cmdlet. To guarantee that the VM is correctly shut down when the Hyper-V host is shut down, use the Name parameter to identify the VM you wish to define and the AutomaticStopAction parameter to provide Shutdown as the value.

Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name HYPER old -AutomaticStopAction Shutdown Set-VM -Name

Hyper-V virtual machines may be saved.

You may need to save the VM you create in the remote Hyper-V host’s PowerShell session to save the VM’s memory state for later usage. Use the Save-VM cmdlet with the Name argument set to the name of the virtual machine you wish to save.

It’s important to note that the VM you wish to preserve must be running.

The Save-VM cmdlet saves the state of the HYPER old virtual machine.The Save-VM cmdlet saves the state of the HYPER old virtual machine.

Managing VM Checkpoints in Hyper-V

You should learn about checkpoints if you need to store the current state of a VM before making changes or rollback VM modifications. Checkpoints are a convenient method to rapidly store a Hyper-V VM’s disk and memory state.

Run the Checkpoint-VM cmdlet on your Hyper-V host, passing in the name of the VM to save and a checkpoint name.

SnapshotName is a parameter name that still refers to Hyper-V 2012 nomenclature. A checkpoint is the same as a snapshot.

HYPER old -SnapshotName Checkpoint-VM MyVMSnapshot

Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.Using Checkpoint-VM, make a MyVMSnapshot snapshot of the HYPER old VM.

After you’ve made a checkpoint, you can use the Get-VMSnapshot cmdlet to get a list of all the snapshots on the Hyper-V host. The VM HYPER old contains three checkpoints, as you can see below.

HYPER old -VMName Get-VMSnapshot

Gets all of the Snapshots for the HYPER old VM.Gets all of the Snapshots for the HYPER old VM.

Conclusion

You’re well on your way to controlling Hyper-V VMs using PowerShell if you’ve completed all of the examples in this tutorial. You should now be able to manage 1, 10, or even 100 virtual machines!

What kinds of jobs do you believe PowerShell and Hyper-V can now automate?

The “nutanix hyper-v installation” is a guide that will help you get started with managing Hyper. The guide includes information on how to install, configure and manage Hyper.

Related Tags

  • hyper-v tutorial pdf
  • get-vm on remote host
  • hyper-v remote management
  • getting started with hyper-v
  • hyper-v powershell

Table of Content