• Blog
  • Webinars
  • Partner
  • Support
  • Contact
  • EN
    • DE
ScriptRunner
  • About us
    • Team
    • Jobs
    • Press
  • Why
  • Use Cases
  • Software
    • ScriptRunner Server
    • ScriptRunner Web Apps
    • ScriptRunner Connectors
    • ScriptRunner ActionPacks
  • Try Now
  • Search
  • Menu Menu
You are here: Home1 / ScriptRunner Blog2 / News3 / 12 tips for managing Hyper-V with PowerShell and Windows Admin Center

12 tips for managing Hyper-V with PowerShell and Windows Admin Center

Author: Thomas Joos | Reading time: 7 minutes | Category: News, PowerShell & Systems, Scripting

The virtualization technology Microsoft Hyper-V can be managed with different tools. Microsoft itself offers numerous options for performing all relevant tasks for managing Hyper-V and controlling VMs.

Managing Hyper-V does not always require complex tools such as System Center Virtual Machine Manager, PowerShell offers numerous possibilities without the need for additional tools.

Of course, the Hyper-V Manager is available as a standard tool, and the new Windows Admin Center also offers numerous functions. In the following, we show 12 interesting tips for controlling Hyper-V with the focus on PowerShell.

Article: 12 tips for managing Hyper-V with PowerShell and Windows Admin Center - Thomas Joos

Table of content

  • Installing Hyper-V from PowerShell and display cmdlets
  • Installing Hyper-V management tools
  • Display all available cmdlets
  • Use PowerShell Direct
  • Run cmdlets from the host on VMs
  • Copy files from host to VMs
  • Managing Virtual Machines and Virtual Switches with Windows Admin Center
  • Working with PowerShell in Windows Admin Center
  • Adjusting Hyper-V settings in the Windows Admin Center
  • Enable Switch Embedded Teaming
  • Displaying the network adapters for connecting to a virtual switch
  • Viewing Virtual Switches Information in PowerShell
  • Related links

Installing Hyper-V from PowerShell and display cmdlets

Use the Install-WindowsFeature Hyper-V cmdlet to install the Hyper-V server role, and the -IncludeManagementTools parameter to install the additional management tools that are required.

These include the PowerShell module and Hyper-V Manager. If the server is to restart automatically, the parameter -restart is added.

Installing Hyper-V management tools

The management tools, without the Hyper-V server role, are installed with the Install-WindowsFeature Hyper-V-Tools command.

Display all available cmdlets

To display a list of all available cmdlets,use the Get-Command cmdlet with the -Module Hyper-V parameter. The output of this command is shown in Figure 1.

Figure 1: PowerShell provides many cmdlets for managing Hyper-V.

Output des Cmdlets „Get-Command“ mit dem Parameter „-Module Hyper-V“

Use PowerShell Direct

Windows Server 2019 enables direct access to a virtual operating system of a virtual machine from a PowerShell session on the host. This feature is called “PowerShell Direct”. It involves opening a session for the VM in the PowerShell with the following command:

Enter-PSSession -VMName

Run cmdlets from the host on VMs

There are also cmdlets that enable you to run PowerShell cmdlets directly on a VM without opening a session first:

Invoke-Command -VMName  -ScriptBlock { Commands }

Copy files from host to VMs

Use the following commands to copy files from the Hyper-V host to VMs via PowerShell Direct

$PSSession = New-PSSession -VMName  -Credential (Get-Credential)

Copy-Item -ToSession $PSSession -Path C:data.bar -Destination C:

Managing Virtual Machines and Virtual Switches with Windows Admin Center

If you use the Windows Admin Center to access a server on which Hyper-V is already installed, you will find the two menu items “Virtual Computers” and “Virtual Switches” in the menu on the left side (see Figure 2).

This allows you to manage the VMs and virtual switches on Hyper-V hosts through your web browser. You can additonaly create and edit virtual servers. You can also control VMs in this way, as well as view the console from your web browser.

Figure 2: The Windows Admin Center can manage virtual machines and virtual switches on Hyper-V hosts.

Screenshot des Windows Admin Centers

Working with PowerShell in Windows Admin Center

In addition, a PowerShell session can be opened on the server using the “PowerShell” menu item in the Windows Admin Center (see Figure 3).

Figure 3: The PowerShell can also be used in the Windows Admin Center to control Hyper-V

Screenshot des Windows Admin Centers. der Tab "Virtuelle Computer" ist geöffnet

Adjusting Hyper-V settings in the Windows Admin Center

Under “Settings”, Hyper-V settings of the host can be adjusted, just like in the Hyper-V Manager. All this works in one session with the Windows Admin Center in your web browser.

Enable Switch Embedded Teaming

The following command creates a virtual switch based on a network team called “SETSwitch” consisting of three network adapters:

New-VMSwitch -name SETswitch -Netadaptername „team1“, „team2“, „team3“ -AllowManagementOS $True -EnableEmbeddedTeaming $true

Displaying the network adapters for connecting to a virtual switch

To see all available adapters, use the Get-NetAdapter cmdlet.

Get-NetAdapter
   [[-Name] <string[]>]
   [-IncludeHidden]
   [-Physical]
   [-CimSession <cimsession[]>]
   [-ThrottleLimit ]
   [-AsJob]
   []</cimsession[]></string[]>

Viewing Virtual Switches Information in PowerShell

PowerShell uses the Get-VMSwitch cmdlet to display information about the virtual network switch.

Get-VMSwitch
   [[-Name] ]
   [[-ResourcePoolName] <string[]>]
   [-SwitchType <vmswitchtype[]>]
   [-CimSession <cimsession[]>]
   [-ComputerName <string[]>]
   [-Credential <pscredential[]>]
   []</pscredential[]></string[]></cimsession[]></vmswitchtype[]></string[]>

For more detailed information about the team, use the Get-VMSwitchTeam cmdlet.

To delete such switches, use the Remove-VMSwitch cmdlet.

Figure 4: Creating and managing network teams for Hyper-V using PowerShell in the Windows Admin Center

Screenshot des Windows Admin Centers. der Tab "Virtuelle Computer" ist geöffnet

Related links

  • Hyper-V PowerShell Module | Windows IT Pro Center
  • Windows Admin Center | Microsoft
  • ScriptRunner ActionPack for Hyper-V
Share this article
  • Share on Facebook
  • Share on Twitter
  • Share on WhatsApp
  • Share on LinkedIn
  • Share on Reddit
  • Share by Mail

These articles might also be interesting for you:

Article: How to Establish Simple Server Monitoring via PowerShell, by Adam BertramScriptRunner Software GmbH

How to Establish Simple Server Monitoring via PowerShell

20. January 2021
Read more
https://www.scriptrunner.com/wp-content/uploads/2021/01/PowerShell-monitoring.png 1000 1000 Adam Bertram https://www.scriptrunner.com/wp-content/uploads/2018/05/ScriptRunner_Logo_RGB-300x45.png Adam Bertram2021-01-20 09:29:522021-01-20 09:34:57How to Establish Simple Server Monitoring via PowerShell
Article: X-mas Fun with PowerShell and ScriptRunnerScriptRunner Software GmbH

X-mas Fun with PowerShell and ScriptRunner

23. December 2020
Read more
https://www.scriptrunner.com/wp-content/uploads/2020/12/xmas-fun-powershell.jpg 1000 1000 Bruno Buyck https://www.scriptrunner.com/wp-content/uploads/2018/05/ScriptRunner_Logo_RGB-300x45.png Bruno Buyck2020-12-23 10:00:412021-01-07 16:26:55X-mas Fun with PowerShell and ScriptRunner
ScriptRunner Software GmbH

Using PowerShell to Create New Citrix MCS Machines

15. December 2020
Read more
https://www.scriptrunner.com/wp-content/uploads/2020/12/citrix-mcs-machines.png 1000 1000 Guy Leech https://www.scriptrunner.com/wp-content/uploads/2018/05/ScriptRunner_Logo_RGB-300x45.png Guy Leech2020-12-15 16:25:392021-01-07 16:31:30Using PowerShell to Create New Citrix MCS Machines

About the author:

Thomas Joos

Thomas Joos is a freelance IT consultant and has been working in IT since 1992. He has published more than 90 practical reference books and writes for numerous IT publications such as c’t, PC Magazin, PC Welt, IT Administrator, Computerwoche and Heise Security.

Latest posts:

  • Article: How to Establish Simple Server Monitoring via PowerShell, by Adam BertramScriptRunner Software GmbHHow to Establish Simple Server Monitoring via PowerShell20. January 2021 - 9:29
  • Article: X-mas Fun with PowerShell and ScriptRunnerScriptRunner Software GmbHX-mas Fun with PowerShell and ScriptRunner23. December 2020 - 10:00
  • ScriptRunner Software GmbHUsing PowerShell to Create New Citrix MCS Machines15. December 2020 - 16:25
  • Article: An Introduction to PowerShell in Citrix Virtual Apps and DesktopsScriptRunner Software GmbHAn Introduction to PowerShell in Citrix Virtual Apps and Desktops7. December 2020 - 17:01
  • Article image: PowerShell AliasingScriptRunner Software GmbHPowerShell Aliasing2. December 2020 - 10:00

Product

  • ScriptRunner Platform
  • ScriptRunner Server
  • ScriptRunner Apps
  • ScriptRunner Connectors
  • Script Collections
  • Licensing
Get your free trial

Solutions

  • IT Administrators
  • IT Team Leaders
  • Use Cases

Resources

  • Blog
  • Documentation
  • Knowledge Base
  • Webinars
  • PowerShell Lexicon
  • PowerShell Poster
  • PowerShell Security Ebook

Company

  • About us
  • Team
  • Jobs
  • Press
  • References
  • Partner

Contact

ScriptRunner Software GmbH
Ludwig-Erhard-Straße 2
76275 Ettlingen
Germany

T: +49 7243 20715-0
M: info(at)scriptrunner.com

Request Demo
© ScriptRunner Software GmbH is a subsidiary of AppSphere AG
  • LinkedIn
  • Xing
  • Twitter
  • Facebook
  • Youtube
  • Imprint
  • Privacy Policy
  • Newsletter
ScriptRunner version 2019R3 We keep on scripting (COVID-19 update)
Scroll to top