none
Using mstsc and cmdkey to automate RDP connection to a two-domain environment RRS feed

  • Question

  • Hello,

    I'm reaching out in hopes someone can provide me some assistance/direction for a issues I'm trying to solve for. I'm looking to create a RDP solution for conference room machines using a powershell script. The conference room machine will exist on (domain#1) while some users will exist on either domain#1 or domain#2 (never both). I would like to have the user input their machine name and username (not storing passwords) and have the script take the user name and machine name, determine which domain the machine resides on, then auto fill mstsc using cmdkey to pass the machine name with the specified domain it resides on so the user simply has to enter their password to proceed. 

    I've got everything working besides the part where i specify the correct domain the user machine resides on. It seems to always default to the domain the conference room machines reside on. 

    Scenario: User is on domain#2, enters username and machine. Machine is detected to reside on domain#2 therefore automating the username field domain#2/username and machine computer.domain#2.com. storing these values using cmdkey by specifying the target: as the machine and user and of course the username with the specified domain. without using the mstsc /prompt this will work however will result in 1 logon failed attempt due to no storing of the password along with the user and machine in the cmdkey value. currently I'm using the mstsc /prompt to avoid the logon failure attempt however will always default to the domain the conference room machines reside on (domain#1)

    Does anyone have any suggestions or have seen similar issues/requests?

    Please help. 

    thank you, 

    Ryan

    Monday, March 12, 2018 5:52 PM

Answers