get-vm - wasn't recognized as name of cmdlet
I figured it out. I needed to run powershell as administrator and then the get-VM returned the list of VM's. I found the answer at MS Technet.
Related videos on Youtube
![Michele](https://i.stack.imgur.com/YcjKJ.jpg?s=256&g=1)
Michele
Updated on September 18, 2022Comments
-
Michele almost 2 years
We are trying to write a powershell script to start/stop our vms, but the
get-vm
command isn't working. The error message isget-vm: the term 'get-vm' is not recognized as the name of a cmdlet, function, script file, or operable program.
The code looks like this:
$temp = Get-VM -Server usa..... | where-object {$_.State -eq 'Running'}
We installed the update for powershell to get version 3 and it's still not working but the error message changed a little to the one I have listed above.
I saw this link: http://social.technet.microsoft.com/Forums/windowsserver/en-US/07decd82-270e-4dd0-b8e8-789d693099dd/powershell-getvm-error?forum=winserverpowershell
But
hyperV
is installed now and shows up when I type:Get-Module -listavailable
At the start of my code I have:
if(!Get-Module -Name HyperV)){import-module Hyperv}
There's also this:
[system.net.dns]::GetHostEntry(ip)
works and so does Get-Host
We tried
Enable-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V -All
but it wasn't recognized as the name of a cmdlet, etc either.
I tried disabling UAC like this link pshyperv.codeplex.com/discussions/359174 but it didn't work. This link shows commands I used: http://www.ehloworld.com/1026
When I typed:
Set-UACStatus -Computer usa...net -Enabled [$false]
it gave the error message that
Set-UACStatus wasn't recognized as the name of a cmdlet
, etc either. It didn't recognize Get-UACStatus either.I'm not sure if there's another thing I need to import to use Get-VM?
-
Michele over 10 yearsWhen I just made it import-module Hyperv, it recognizes Get-VM now, but it isn't working to do $temp = Get-VM -Name usa0xxx. $temp is null.
-
Michele over 10 yearsI wonder if it could be that powershell doesn't have the administrative privileges that I do with using my AD login?
-