From Svendsen Tech PowerShell Wiki

I knew about TeamViewer, which is still offering a free version for non-commercial use, when I wanted to set up something to remote control my mom's computer. It's truly priceless in my case, since my mother is 97 % incapable of conveying anything even remotely sensible when it comes to what she wants help with. She'll read random text on the screen that may or may not be relevant at all. Anyway, that is a whole other story.

I had a requirement of not installing a persistent version, for security reasons. Now, it isn't that hard to create a bookmark for your grandpa to click on to get to teamviewer.com, and then click on the link to join a remote control session, but what if we could make it simpler still, for the sake of our sanity? Wouldn't it be nice with a simple shortcut on the desktop that did all the work, without installing the persistent version? If they make auto-updates smooth, that'll work too, I guess. No UAC popups, she always cancels those. "WHAT DOES AN ORACLE WANT WITH MY COMPUTER, SOUNDS LIKE A FISHY CHARACTER, I GUESS I WON'T UPDATE THE BROWSER JAVA PLUGIN THAT WAS NEEDED FOR ONLINE BANKING FOR YEARS IN NORWAY" (we finally got rid of it). Sorry about the outburst. Ahem.

I also remembered that the URL used to be extremely memory-friendly and has been the same for years. I was happy to see that as of 2015-08-26 it is still the same (with geolocation and all sorts of jazz), so I pray it lasts for a few more years, and that they don't actively prevent this method depicted in this article for some reason (hey, you get that ad when the session closes, be happy with that - oh, and for you setting this up: instruct your uncle to close that without clicking/buying anything ;) ).

To cut to the chase (btw, I hate car chases, they've been done to death, revived thousands of times and then killed again, but I'm weird), here's PowerShell version 2-compatible code for a script to download and launch the English-language TeamViewer executable, which means it will work for all you glorious Windows 7 users out there:

$Destination = "$Env:Temp\TeamViewerQS_en.exe"; $WebClient = New-Object -TypeName System.Net.WebClient; #$StreamsDestination = "$Env:Temp\streams-from-sysinternals.exe"; $WebClient.DownloadFile("http://download.teamviewer.com/download/TeamViewerQS_en.exe", $Destination); #$WebClient.DownloadFile('https://live.sysinternals.com/tools/streams.exe', $StreamsDestination); #& $StreamsDestination /accepteula -d $Destination; Start-Process -FilePath $Destination









Tweet

Download PSv2-compatible version

The commented-out lines are for if you want to unblock the file as well (delete alternate NTFS stream data, such as the zone identifier). I found that I didn't need them on my test computer, so I commented them out, but left them in, in case someone else's mileage varies.

Download PSv3-and-up-compatible version

With PowerShell version 3 and up you can use this code below. Windows 8 is the first version to ship with PSv3 in-the-box. Windows 8.1 has PowerShell v4 and can also use this code below. Windows 10 and newer as well.

$Destination = "$Env:Temp\TeamViewerQS_en.exe"; Invoke-WebRequest -Uri "http://download.teamviewer.com/download/TeamViewerQS_en.exe" -OutFile $Destination; Unblock-File -Path $Destination; Start-Process $Destination

Download Invoke-TeamViewerNew.ps1.txt - right-click, download and save as .ps1.

That simple double-click shortcut

But do you want your old aunt to have to right-click the shortcut on her desktop and choose "Run with PowerShell"?! That's way too tricky, so let's make a simple cmd batch file that we can make a DOUBLE-CLICK(!) shortcut to, that calls PowerShell to do the heavy lifting via the -EncodedCommand parameter (quotes in the code is tricky).

First, I base64-encoded the content of the .ps1 file and saved it in "Invoke-TeamViewerBASE64.txt":

[Convert]::ToBase64String( [System.Text.Encoding]::Unicode.GetBytes((Get-Content .\Invoke-TeamViewer.ps1)) ) | sc -enc Ascii Invoke-TeamViewerBASE64.txt

Download pre-made batch file

Then we can create a batch cmd file wrapper that calls that base64-encoded string with -EncodedCommand passed to powershell.exe, that will look like this for the English version of TeamViewer:

powershell.exe -ExecutionPolicy Bypass -NoProfile -EncodedCommand JABEAGUAcwB0AGkAbgBhAHQAaQBvAG4AIAA9ACAAIgAkAEUAbgB2ADoAVABlAG0AcABcAFQAZQBhAG0AVgBpAGUAdwBlAHIAUQBTAF8AZQBuAC4AZQB4AGUAIgA7ACAASQBuAHYAbwBrAGUALQBXAGUAYgBSAGUAcQB1AGUAcwB0ACAALQBVAHIAaQAgACIAaAB0AHQAcAA6AC8ALwBkAG8AdwBuAGwAbwBhAGQALgB0AGUAYQBtAHYAaQBlAHcAZQByAC4AYwBvAG0ALwBkAG8AdwBuAGwAbwBhAGQALwBUAGUAYQBtAFYAaQBlAHcAZQByAFEAUwBfAGUAbgAuAGUAeABlACIAIAAtAE8AdQB0AEYAaQBsAGUAIAAkAEQAZQBzAHQAaQBuAGEAdABpAG8AbgA7ACAAVQBuAGIAbABvAGMAawAtAEYAaQBsAGUAIAAtAFAAYQB0AGgAIAAkAEQAZQBzAHQAaQBuAGEAdABpAG8AbgA7ACAAUwB0AGEAcgB0AC0AUAByAG8AYwBlAHMAcwAgACQARABlAHMAdABpAG4AYQB0AGkAbwBuAA==

The -EncodedCommand needs to be all on one line.

Download pre-made cmd/batch file Invoke-TeamViewer.txt - right-click, download and rename to .cmd (not .txt).

When you run that batch file, you should shortly after see this, or however they made it look in the future when this article is old:

Then you fire up the TeamViewer client on your end and do your work.

Hope this is useful to someone... Be well if you're a good person, otherwise you can go acquire a toothache or something.