Last active
January 14, 2016 17:16
-
-
Save josy1024/917715eef3a87a3c0bf3 to your computer and use it in GitHub Desktop.
prestage remote desktop logons for other users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prestage remote desktop logons for other users... (have to know passwords # | |
# author: josef lahmer | |
# | |
# USE https://gallery.technet.microsoft.com/scriptcenter/Connect-Mstsc-Open-RDP-2064b10b | |
# https://gist.github.com/josy1024/917715eef3a87a3c0bf3 | |
# optimisations: | |
# (would be nice to know if i can store password hashes)? (to avoid clear text passwords) | |
# run this script bevor the users are going to work (you have to know their passwords!!) | |
# autoadminlogon on reboot on terminalservers? | |
. .\Connect-Mstsc.ps1 | |
# or from network | |
# . "\\server\share\Connect-Mstsc.ps1" | |
# for every line change server and logon credentials | |
Connect-Mstsc -ComputerName servername -User 'domain\user' -Password 'password' | |
## option with secure password string.... | |
$user = "domain\user" | |
$passwordfile="passwordfile.txt" | |
### set password with: | |
# read-host -assecurestring | convertfrom-securestring | out-file passwordfile.txt | |
$pass = (get-content -path $passwordfile | convertto-securestring) | |
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $user,$pass | |
Connect-Mstsc -ComputerName servername -Credential $cred | |
# | |
# .... | |
# wait 3 minutes to sure logonprocess finished... | |
start-sleep 180 | |
# reset mstsc connections for this user session | |
taskkill /F /FI "USERNAME eq %USERNAME%" /IM "mstsc.exe" | |
# wait for the useres to go to work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment