Created
April 23, 2020 17:09
-
-
Save Stanislasss/ae380b9d06a1e43a6d78dfa0b920de87 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $NodesList = [Environment]::GetEnvironmentVariable('NODES_LIST', 'User').Split(",") | |
| $NodesList | ForEach-Object { | |
| # Generate cached credentials for RDP session | |
| cmdkey.exe /generic:$_ /user:MYDOMAIN\MYUSER /pass:"MYPASSWORD" | |
| write-Output "Activating node $_ through RDP session..." | |
| $app = Start-Process -FilePath C:\Windows\System32\mstsc.exe -ArgumentList "/v:$_" -PassThru | |
| Start-Sleep -s 60 | |
| # Deleting cached credentials for security purpose | |
| cmdkey.exe /del:$_ | |
| $app | Stop-Process | |
| write-Output "Stopped RDP connection to node $_, the node should now be online" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment