Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 627
  • Last Modified:

Powershell Hyper-V Module on Server 2012 R2

I don't use powershell very much and I don't know if it's just me - but it seems every time I need to use powershell (and I always happen to be on different versions of Windows server) that something is different and even though I documented how I did something last time, it simply doesn't work in all cases.

Here's where I'm stuck today...

I'm on a Windows Server 2012 R2 machine, it has the Hyper-V role installed (and has running VM machines)


I'm trying to get a list of all VM's and the virtual network that their NIC is connected to.

But my issue is at the very basics, I can't even get output from "Get-VM"

I type it in, and nothing happens (no error, but no output, I just end up at the next line)

PS C:\> Get-VM
PS C:\>


If I type this:
Get-Command –Module Hyper-V

I get a list of all the Cmdlet's, for example:


CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Cmdlet          Add-VMDvdDrive                                     Hyper-V
Cmdlet          Add-VMFibreChannelHba                              Hyper-V
Cmdlet          Add-VMHardDiskDrive                                Hyper-V
Cmdlet          Add-VMMigrationNetwork                             Hyper-VCommandType     Name                                               ModuleName
-----------     ----                                               ----------
Cmdlet          Add-VMDvdDrive                                     Hyper-V
Cmdlet          Add-VMFibreChannelHba                              Hyper-V
Cmdlet          Add-VMHardDiskDrive                                Hyper-V
Cmdlet          Add-VMMigrationNetwork                             Hyper-V
...etc

Open in new window




Just in case, I also imported the Hyper-V module like this:

PS C:\> Import-Module “C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Hyper-V\Hyper-V.psd1”
PS C:\>


Here is the Powershell version info:

PS C:\> $psversiontable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34011
BuildVersion                   6.3.9600.16394
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

Open in new window




So what am I missing?  If the Hyper-V module wasn't installed I assume typing Get-VM would give me an error, but it doesn't, yet it doesn't give any output either.

Also, if you can advise on the full command to list all VM's and their virtual switches that would be helpful too.


Thanks in advance
0
Vas
Asked:
Vas
1 Solution
 
Abdul Khadja AlaoudineCommented:
Are you running PowerShell as administrator? If not, make sure you running it as administrator.
0
 
VasAuthor Commented:
OMG that was it thank you!

Wow Microsoft could have at least added some kind of permissions error instead of nothing, they have no issues spitting out errors in Powershell for everything else.


Thanks Abdul.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now