Get-ChildItem `
'HKCU:\Software\Microsoft\Terminal Server Client\Servers' |
ForEach-Object {
$p = Get-ItemProperty $_.PSPath
[PSCustomObject]@{
Server = $_.PSChildName
Username = $p.UsernameHint
}
}
Server Username
------ --------
10.15.7.15 administrator@itdrde.local
10.15.7.16 administrator@other.local
10.15.7.18 vasyasecond@other.local
10.15.7.60 DESKTOP-0DRJUG2\administrator
10.15.7.65 administrator@beta.local
10.23.29.51 ex5\Administrator
10.23.29.54 ex5\Administrator
10.23.4.10 MicrosoftAccount\administrator
10.23.4.11 MicrosoftAccount\administrator
10.23.4.17 DE1\Administrator
10.23.4.19 DE1\Administrator
192.168.0.108 nx11118@yandex.ru
192.168.0.112 dmitriano@outlook.com
192.168.0.118 dmitriano
192.168.0.123 administrator@my.local
192.168.0.132 dmitriano
192.168.0.145 LENOVO16\dmitriano
192.168.0.170 LENOVO16\dmitriano
other.local administrator@other.local
Connecting:
mstsc /v:10.23.29.54
or
mstsc /v:10.23.29.54 /prompt
with without querying the password:
cmdkey /generic:TERMSRV/10.23.29.54 `
/user:ex5\Administrator `
/pass:MyPassword
and then
mstsc /v:10.23.29.54
or with a single string:
cmdkey /generic:TERMSRV/10.23.29.54 /user:ex5\Administrator /pass:MyPassword; mstsc /v:10.23.29.54
or without UI:
Enter-PSSession -ComputerName 10.23.29.54 -Credential ex5\Administrator

