Sending keystrokes with PowerShell and including a percent sign in the text

Viewed 3605

I have this long string of characters I need to send exactly as show in the text file I am reading it from ($token = Get-Content $token_txt). This string of characters has a few percent signs in it. They need to be included in the string of characters. Every time I do a SendKeys using either wshell, VB, or WASP it removes the percent sign and the next two characters from the text. I am sure its thinking its a special character and some keystroke command or something. How do I get the system to ignore the percent signs and not treat them as special characters?

Here is an example of the string I am reading from the text file and its set to the variable $token:

YzY5FlNDItMjllctZjA4ZDVkNzUxNWM3LTE1MzMyMzMw%0AMTY2NDJ8VjBPd1BhT1JVSmtwWkxaZk1tRkNCbGNONzl5SndHb3YyQVZNVlNX%0AQWdMQT0%3D%0A

As you can see there are a few percent signs in the token however these need to be sent exactly as shown. When I see it get sent it makes it

YzY5FlNDItMjllctZjA4ZDVkNzUxNWM3LTE1MzMyMzMwMTY2NDJ8VjBPd1BhT1JVSmtwWkxaZk1tRkNCbGNONzl5SndHb3YyQVZNVlNXQWdMQT0

Like I said I've tried wshell, VB, WASP to all send the keys to a PuTTY window and its not sending it correctly.

If I just have it display the variable $token in PowerShell it displays it properly with the percent signs. Its only when I send the keys when it removes the special characters.

Here is the three ways I tried sending it

$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('putty')
Sleep 1
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait($token);

add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms
[Microsoft.VisualBasic.Interaction]::AppActivate("putty")
[System.Windows.Forms.SendKeys]::SendWait($token)

Select-Window putty | Send-Keys $token
Select-Window putty | Send-Keys "{ENTER}"

Any help would be greatly appreciated.

1 Answers
Related