Cry about...
Windows Hyper-V-Server
PowerShell - the real Hyper-V-Server toolbox
To do almost anything of note on a Hyper-V-Server you need to use PowerShell.
PowerShell is started from the command line simply by running powershell:
C:\Users\Administrator>powershell
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.
PS C:\Users\Administrator>
![]()
You can perform some basic administration using sconfig, but powershell is what you need to use in order to create and administer virtual machines.
Contents:
PowerShell Snap-Ins and Modules
Whilst it is a bit simplistic, you can think of PowerShell as being a toolbox which in turn contains a number of toolkits. Each toolkit must be loaded before it can be used. These toolkits can be either "snap-ins" or "modules".
PowerShell Modules
To see what modules are available use Get-Module
-ListAvailable thus:
PS C:\Users\Administrator> Get-Module -ListAvailable
PowerShell commands are not case sensitive, so you could just as
easily have typed "get-module" (i.e. in all lower case).
To add a snap-in to make it available to the current session use
Import-Module thus:
PS C:\Users\Administrator> Import-Module Hyper-V
Import-Module can be abbreviated to simply ipmo, so the following is equivalent to the above:
PS C:\Users\Administrator> ipmo Hyper-V
To see which modules have already been imported into the session use
Get-Module (or simply "gmo"):
PS C:\Users\Administrator> Get-Module
ModuleType Name
ExportedCommands
---------- ---- ----------------
Binary Hyper-V {Add-VMDvdDrive, Add-VMFibreC...
Manifest Microsoft.PowerShell.Management {Add-Computer, Add-Content, C...
Manifest Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-...
PS C:\Users\Administrator>
![]()
The above also shows the three modules pre-loaded on Windows Hyper-V server.
On Hyper-V server (2012) the following modules are pre-installed and available to be imported:
| Module |
|---|
| BestPractices |
| BitsTransfer |
| CimCmdlets |
| DirectAccessClientComponents |
| Dism |
| DnsClient |
| Hyper-V |
| International |
| iSCSI |
| IcsciTarget |
| Kds |
| Microsoft.PowerShell.Diagnostics |
| Microsoft.PowerShell.Host |
| Microsoft.PowerShell.Management |
| Microsoft.PowerShell.Security |
| Microsoft.PowerShell.Utility |
| Microsoft.WSMan.Management |
| MsDtc |
| NetAdapter |
| NetConnection |
| NetLbfo |
| NetQos |
| NetSecurity |
| NetSecurityTeam |
| NetTCPIP |
| NetWNV |
| NetworkConnectivityStatus |
| NetworkTransition |
| NFS |
| PKI |
| PSDiagnostics |
| PSScheduledJob |
| PSWorkflow |
| PSWorkflowUtility |
| RemoteDesktop |
| ServerCore |
| ServerManager |
| ServerManagerTasks |
| SmbShare |
| SmbWitness |
| Storage |
| UserAccessLogging |
| Wdac |
| WindowsErrorReporting |
PowerShell Snap-Ins
To see what snap-ins are available use Get-PSSnapin
-registered thus:
PS C:\Users\Administrator> Get-PSSnapin -registered
PowerShell commands are not case sensitive, so you could just as
easily have typed "get-pssnapin" (i.e. in all lower case).
To add a snap-in to make it available to the current session use Add-PSSnapin thus:
PS C:\Users\Administrator> Get-PSSnapin microsoft.systemcenter.virtualmachinemanager
which will load the snapin called "microsoft.systemcenter.virtualmachinemanager". You can load more than one snap-in at a time, just separate each name with a comma. Get-PSSnapin takes an optional flag "-name" which explicitly states that there is a name following to load, but this is optional so it is often quicker to leave it out.
If you wanted to load all the available registered snap-ins all at once use:
PS C:\Users\Administrator> Get-PSSnapin -registered | Get-PSSnapin -passthru
Should you wish to unload a snap-in from the current session use "Remove-PSSnapin", thus:
PS C:\Users\Administrator> Remove-PSSnapin microsoft.systemcenter.virtualmachinemanager
About the author: Brian Cryer is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.