Share via


Passing credentials to VMConnect?

Question

Wednesday, May 6, 2015 4:56 PM

All,

I am tasked with developing a solution for a test automation solution on a Hyper-V platform.  The automated tests require the ability to to run tests that interact with the desktop of the VM.  These tests will run as part of the nightly build and deployment and as such there will not be individuals present to unlock/tend to the VM's.  My intent is to establish a VMConnect 'host' that will run some type of script on startup to launch VMConnect sessions to X number of VM's, login to a domain account and be ready to run these UI based automated tests.

Does anyone know this if this is possible with VMConnect or is this something that would need to be implemented via group policy on the VM's?  

Also, slightly off topic but I am having difficulties making a VMConnect connection when running via command line, running the app manually works great but when I run via command line I get this:

Hyper-V cannot find a virtual machine with the name '<machinename>'.  Verify that your user account has permission to access virtual machines.  Or use Run as Administrator and try again.

I've tried running from an administrator command prompt and using the runas command with the same results.

Any ideas?

All replies (6)

Wednesday, May 6, 2015 5:13 PM ✅Answered

Unless you have a requirement to use the VM Console, you need to use and RDP connection where you can provide credentials and you can also drive the RDP connection element itself.

Brian Ehlert
http://ITProctology.blogspot.com
Learn. Apply. Repeat.


Wednesday, May 13, 2015 7:36 AM ✅Answered | 1 vote

Hi Sir,

>> I have come across cmdkey wherein you're able to store credentials for connecting to other machines.  

Based on my understanding , cmdkey is used by host to connect to other computer but not for VMconnect.exe .

And VMconnect.exe doesn't has a parameter to pass the credential to VM :

http://blogs.msdn.com/b/mikekol/archive/2008/12/02/how-to-use-vmconnect-to-create-an-rdp-like-shortcut-directly-to-your-vms.aspx

Best Regards,

Elton Ji

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] .


Wednesday, May 6, 2015 6:38 PM | 1 vote

Since I wrote the above message, I have come across cmdkey wherein you're able to store credentials for connecting to other machines.  Using mstsc  I was able to establish a connection to the VM however I am still unable to do so using VMConnect as I still get the message about insufficient rights.

Does anyone have experience with successfully connecting to a vm using VMConnect from the command line?  


Wednesday, May 6, 2015 7:47 PM

Vmconnect relies on Kerberos.

Brian Ehlert
http://ITProctology.blogspot.com
Learn. Apply. Repeat.


Wednesday, May 20, 2015 3:19 PM

Hi Sir,

Any update ?

Best Regards,

Elton Ji

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] .


Sunday, November 8, 2015 6:09 PM | 1 vote

Hello,

I just tried it in 2016 and it seems like there is an option to provide credentials, either via credman (cmdkey) oder by /user and /password. The problem is, that it doesnt let you connect to local VMs with credentials saying, that "user credentials cannot be used for local connections". So for Cluster VMs oder from an admin PC it should work fine with this:

C:\WINDOWS\system32\VmConnect.exe "{HYPER-V SERVERNAME}" "{VMNAME}" [/credential LegacyGeneric:target={CREDENTIALNAME} | /user {USERNAME} /password {PASSWORD}].

With cmdkey you have to store the credentials temporary. This can be achieved by "cmdkey /generic:{HYPER-V SERVER}\VMNAME} /user:{USERNAME} /pass:{PASSWORD}".

I hope this helps someone.