1

I tried run get-vm command on windows powershell. It is throwing this exception:

"Error in script : The term 'Get-VM' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."

but I run same command on system center powershell it's run successful. But i need run on windows powershell. can i run it on windows powershell?

1
  • Are you running ps 2.0 trying to remote control a hyper-v server? If so you need to download the RSAT tools if I remember correctly and activate the "hyper-v powershell module" windows feature Commented Jan 21, 2013 at 9:03

1 Answer 1

2

Import the VMM snapin. System Center's Powershell shortcut loads it per default. Vanilla Powershell doesn't.

Use Get-PSSnapin -Registered to list all available snap-ins. The one you are looking for is Microsoft.SystemCenter.VirtualMachineManager

Load the snap-in: Add-PSSnapin -Name Microsoft.SystemCenter.VirtualMachineManager

Get and set default VMM Server: get-vmmserver myVMMServer.VMMServeror use-VMMServer` switch to specify the VMM server the cmdlet is going to interact with.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for answer. i was using "Get-PSSnapin -Registered" powershell was showing 'WDeploySnapin3.0'. i was using "Get-PSSnapin" i was seeing 'Microsoft.Powershell.Core' but i run get-vm command on virtual machine manager powershell console is't not throwing any error
i find different solution. First set Execution Policy to RemoteSigned by 'Set-ExecutionPolicy RemoteSigned' and Import Virtual Machine Module by 'Import-Module "C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager\bin\psModules\virtualmachinemanager\virtualmachinemanager.psd1" and i run get-vm script successfully. But i call same script by c# this script not working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.