Last active
November 11, 2024 14:44
-
-
Save 1mm0rt41PC/f1ed27561fcdbfdedaac0eaeb672f5ea to your computer and use it in GitHub Desktop.
This script allows Tailscale install even in a hardened context where WPAD service is disabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sc.exe stop tailscale | |
killall /f /im tailscale.exe | |
killall /f /im tailscale-ipn.exe | |
killall /f /im tailscaled.exe | |
sc.exe delete tailscale | |
rm -Force -Recurse -ErrorAction SilentlyContinue "C:\Program Files\Tailscale" | |
$l=curl.exe -k -L https://pkgs.tailscale.com/stable/ | out-string | Select-String -Pattern '"tailscale-setup-([0-9\.]+)-amd64.msi"' | |
$version = $l.Matches[0].Groups[1].Value | |
$output=$env:TMP | |
rm -Force -ErrorAction SilentlyContinue "$output\tailscale*.*" | |
curl.exe -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" -L https://pkgs.tailscale.com/stable/tailscale-setup-${version}-amd64.msi --output $output\tailscale-setup-latest.msi | |
msiexec.exe /a "$output\tailscale-setup-latest.msi" /qb 'TARGETDIR="C:\Program Files\"' /quiet | |
ping -n 10 127.0.0.1 | |
rm -Force -ErrorAction SilentlyContinue "C:\Program Files\tailscale-setup-latest.msi" | |
if ( -not ($env:PATH).Contains('Tailscale') ){ | |
$env:PATH += ';C:\Program Files\Tailscale' | |
[Environment]::SetEnvironmentVariable("PATH", $env:PATH, [System.EnvironmentVariableTarget]::User); | |
} | |
sc.exe create tailscale binPath= "C:\Program Files\Tailscale\tailscaled.exe" displayName= TailScale start= auto | |
sc.exe start tailscale | |
& 'C:\Program Files\Tailscale\tailscale.exe' up | |
& 'C:\Program Files\Tailscale\tailscale.exe' status | |
$Trigger = New-ScheduledTaskTrigger -AtLogOn | |
$Action = New-ScheduledTaskAction -Execute "C:\Program Files\Tailscale\tailscale-ipn.exe" | |
$Setting = New-ScheduledTaskSettingsSet -RestartOnIdle -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -DisallowHardTerminate -DontStopOnIdleEnd:$true -RestartCount 60 -RestartInterval (New-TimeSpan -Minutes 1) -ExecutionTimeLimit 0 | |
Get-LocalUser | ?{$_.Enabled -eq $true} | %{ | |
$taskName = "[TailScale] IPN for $($_.Name)" | |
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue | |
Register-ScheduledTask -TaskName $taskName -Trigger $Trigger -User $_.Name -Action $Action -Settings $Setting -Force > $null | |
Start-ScheduledTask -TaskName $taskName | |
} | |
& 'C:\Program Files\Tailscale\tailscale.exe' status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment