0

Thank you in advance for anyone taking a look into this.

I'm currently trying to deploy TeamViewer via Intune that only support MSI files for deployment. However, TeamViewer has a feature called account assignment which it comes in form of an executable. Since Intune doesn't allow you deploy exe files, please correct me if I'm wrong. I have resulted in using a PowerShell script that will download the necessary files and then install.

My goal is to have the files stored in the cloud like onedrive or Dropbox. The problem there is the public link doesn't point to the file directly as its a redirect.

For example https://www.dropbox.com/x/xyzd/TeamViewer_Assignment.exe?dl=0 --> https://www.dropbox.com/x/xyzd/TeamViewer_Assignment.exe

or

https://1drv.ms/u/s!Avjfi0upMYg9haNVTMpdoPGdstex --> https://1drv.ms/u/s/teamviewer.exe

if both links were to end with the file extension (.exe), then it would be no problem. But I would like to use Teamviewer links (get.teamviewer.com/myhost redirects https://download.teamviewer.com/u/id12345/TeamViewer.exe hoping this will help a lot more people. As opposed to having a cloud storage account.

https://download.teamviewer.com/u/id12345/TeamViewer.exe is not a permanent link either, and it has an expiration time.

Things I've tried:

$url = "https://get.teamviewer.com/mycustomhost"
$output = "$PSScriptRoot\myhost.exe"
$start_time = Get-Date

Invoke-WebRequest -Uri $url -OutFile $output
Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) 
second(s)"

$url = "http://get.teamviewer.com/myhost"
$output = "$PSScriptRoot\myhost.exe"
$start_time = Get-Date

$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $output)
#OR
(New-Object System.Net.WebClient).DownloadFile($url, $output)

Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) 
second(s)"

$rep=Invoke-WebRequest 
http://www.get.teamviewer.com/myhost -MaximumRedirection 
0 
$rep.Links | where {$_.innerText -eq "click here"} |select -expand href 

None of those examples worked I tried other combination from bits and pieces over the net but no go.

Alfonso Jr
  • 39
  • 8

1 Answers1

1

You can use the following URI for all of your examples:

https://customdesign.teamviewer.com/download/version_12x/myhost/TeamViewerQS.exe

You can get this URI for your download in Chrome in the following way:

  1. Download TeamViewer
  2. Open the Download History
  3. Right click the entry for the TeamViewer download and copy the download URI.

Edit:

You can parse the download site for the real link with the following command:

$downloadPage = Invoke-WebRequest -Uri https://get.teamviewer.com/myhost
$downloadLink = $request.ParsedHtml.getElementById('MasterBodyContent_btnRetry').href

Now you can use the '$downloadLink' variable to download the executable with any of your scripts. You may have to change this if the download page for TeamViewer changes.

Just search for the id of the 'Try again' button on the download page. Then you can edit my code to get the appropriate element and attribute.

Leo
  • 66
  • 3
  • Hello Leo, Thank you for the feedback. – Alfonso Jr Jan 15 '18 at 15:43
  • will confirm shortly. – Alfonso Jr Jan 15 '18 at 15:50
  • That works but is not necessarily what I was looking for because it still using the direct link. Which it can expire after a certain amount of time. So eventually the script could fail. – Alfonso Jr Jan 15 '18 at 21:08
  • It's the way we use it for our costumized installers. I wanted to try to parse the web page for the installer URI but it was a bit late. – Leo Jan 16 '18 at 12:17
  • I added the code you need to parse the initial html and search for the element that contains the download link to save the link in a variable. – Leo Jan 16 '18 at 12:33