Skip to content

Instantly share code, notes, and snippets.

@ImaginaryDevelopment
Created November 10, 2023 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ImaginaryDevelopment/bbf31aa4b463e146715ad86e0720fe3f to your computer and use it in GitHub Desktop.
Save ImaginaryDevelopment/bbf31aa4b463e146715ad86e0720fe3f to your computer and use it in GitHub Desktop.
clipboard substitute
<#
SEND Text just types out the text in the input to send over rdp where copy and paste is not enabled.
1. put the text you want to send as the $input variable
2. set timeout (optional) to the number of seconds you want to wait until it starts to send
3. Start script
4. before the timeout is complete, put the mouse focus on the window you want input the text to
RDP -> Notepad on remote system
5. Wait for the text to fully send. Depending on how long the string is, it could take a while.
Cool parts:
You can use command keys (such as Enter, or DEL keys as well)
https://www.jesusninoc.com/11/05/simulate-key-press-by-user-with-sendkeys-and-powershell/
Potential problems:
Network issues could cause lost keystrokes over rdp. verify the string was sent properly
Really only works with standard US character keyboard set. I tried it with chinese characters and the script failed.
#>
$input = "[System.Net.ServicePointManager]::SecurityProtocol = 'TLS12'{ENTER}Something else"
$timeout = 5
do {
Write-Host "Sending Text in ${timeout} seconds"
$timeout--
Start-Sleep -Seconds 1
} while ($timeout -gt 0)
Write-Host "Sending Text" -NoNewline
[System.Windows.Forms.SendKeys]::SendWait($input)
Write-Host "... done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment