Added from Evernote export

This commit is contained in:
DistractADD
2024-02-02 08:54:43 +10:00
parent cfddd4fad2
commit e326cd97c0
11 changed files with 1531 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<#
.Synopsis Detects, downloads, installs and configures the latest version of TeamViewer.
.Notes
Requires TeamViewer 14.
TeamViewer Installation Documentation
https://community.teamviewer.com/t5/Knowledge-Base/Mass-deployment-improvements/ta-p/39639
#>
$ConfigurationID = "64uyck9"
$ApiToken = "6615740-y9LI6bdNq5QtaDtiGVTN"
$ComputerName = $ENV:COMPUTERNAME
if (Test-Path 'C:\Program Files (x86)\TeamViewer\TeamViewer.exe') {
Write-Host 'Team Viewer already installed.'
return
}
Write-Host 'Installing TeamViewer.'
Write-Host 'Downloading TeamViewer Host Setup.'
$SetupFilePath = Join-Path $ENV:TEMP "TeamViewer_Host_Setup-idc$($ConfigurationID).exe"
$response = Invoke-RestMethod "https://get.teamviewer.com/$ConfigurationID"
$json = '{}'
if ($response -match 'configId = "(?<ConfigId>[^"]+).*\n.*version = "(?<Version>[^"]+).*\n.*isCustomModule = (?<IsCustomModule>[^"]+);.*\n.*subdomain = "(?<Subdomain>[^"]+)(?<ConnectionId>)' ) {
$Matches.Remove(0)
$Matches['IsCustomModule'] = if ($Matches['IsCustomModule'] -eq 'true') { $true } else { $false }
$json = [PsCustomObject]$Matches | ConvertTo-Json
}
else {
throw 'Expected JSON values not found in initial HTML page'
}
$DownloadUri = Invoke-RestMethod -Uri 'https://get.teamviewer.com/api/CustomDesign' -Method Post -Body $json -ContentType 'application/json'
Invoke-WebRequest -Uri $DownloadUri -OutFile $SetupFilePath
if (-not (Test-Path $SetupFilePath)) {
throw 'TeamViewer_Setup.exe failed to download.'
}
Write-Host 'Installing.'
& $SetupFilePath /S | Write-Output
Write-Debug "$SetupFilePath LastExitCode = $LASTEXITCODE"
Write-Host 'Configuring'
& "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" assign --api-token $ApiToken --grant-easy-access --reassign --alias $ComputerName | Write-Output
Write-Debug "TeamViewer.exe assign LastExitCode = $LASTEXITCODE"
Write-Host 'Cleaning up.'
$SetupTempFolder = Join-Path $ENV:TEMP 'TeamViewer'
$SetupFilePath, $SetupTempFolder | Remove-Item -Recurse
Write-Host 'Complete.'

View File

@@ -0,0 +1,51 @@
param([switch]$Elevated)
function Check-Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if ((Check-Admin) -eq $false)  {
if ($elevated)
{
# could not elevate, quit
}
 
else {
 
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
}
exit
}
$TempInstallDir = "c:\teamviewer_install\"
if (Test-Path $TempInstallDir) {
Remove-Item $TempInstallDir -Recurse -Force
}
else
{
Write-Host "Install Start"
}
$TeamViewerFileName = "C:\Program Files (x86)\TeamViewer\TeamViewer.exe"
$TeamViewer64FileName = "C:\Program Files\TeamViewer\TeamViewer.exe"
function not-exist { -not (Test-Path -Path $TeamViewer64FileName) }
function not-exist { -not (Test-Path -Path $TeamViewerFileName) }
if (-not (Test-Path -Path $TeamViewerFileName)) {}
if (-not (Test-Path -Path $TeamViewer64FileName)) {
mkdir c:\teamviewer_install
$url = "https://download.teamviewer.com/download/version_15x/TeamViewer_MSI32.zip"
$output = "c:\teamviewer_install\TeamviewerHost.zip"
$tvdir = "c:\teamviewer_install"
$start_time = Get-Date
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $output)
Write-Host "Teamviewer Downloaded"
sleep 3
Expand-Archive -LiteralPath $output -DestinationPath $tvdir -Force
msiexec.exe /i "c:\teamviewer_install\Host\Teamviewer_Host.msi" /qn CUSTOMCONFIGID=6988pev APITOKEN=6581446-B1aEz7nIk9k92p4G7C1R ASSIGNMENTOPTIONS="--grant-easy-access"
Write-Host "Teamviewer Installed"
}
Else
{
Write-Host "TeamViewer Already Installed"
}