Powershell: use logged on credentials to logon to RDP?

janhoedt
janhoedt used Ask the Experts™
on
Hi,

Is there a way to pass credentials with which I'm logged on to my Windows system to an RDP session (mostly Windows 7/2012)?
So that would be  mstsc /admin /v:$computername
then using  @runas /user:$env:USERDOMAIN\$env:USERNAME  with cachedcredentials.

Please advise.
J.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
NEnterprise Systems Engineer

Commented:
Hello,

I was looking for something very similar yesterday and found the following:

https://stackoverflow.com/questions/3917779/get-current-users-credentials-object-in-powershell-without-prompting

While not the same scenario as yourself it certainly implies that you can't pass the cached credentials.  I'm no expert on powershell though so happy to stand corrected!
Technical Architect - HA/Compute/Storage
Commented:
To set things up so that a domain user can log on to internal Remote Desktop Services Session Hosts and RemoteApp services Single-Sign On needs to be set up in Group Policy.

Once that's done then any connection to an RDS setup would automagically log the user in.

This should apply for a Virtual Desktop Infrastructure (VDI) setup with desktop operating systems served via RDS.

Author

Commented:
what gpo to set/use?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial