get-vm - wasn't recognized as name of cmdlet
We are trying to write a powershell script to start/stop our vms, but the get-vm command isn't working. The error message is
get-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:
But hyperV is installed now and shows up when I type:
Get-Module -listavailableAt 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 but it didn't work. This link shows commands I used:
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?
21 Answer
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.
0