Skip to content

Instantly share code, notes, and snippets.

@1mm0rt41PC
Created May 14, 2024 10:35
Show Gist options
  • Save 1mm0rt41PC/d2264880f1c950e429d71e1a2758f506 to your computer and use it in GitHub Desktop.
Save 1mm0rt41PC/d2264880f1c950e429d71e1a2758f506 to your computer and use it in GitHub Desktop.
$l=curl.exe -k -L https://pkgs.tailscale.com/stable/ 2>$null | out-string | Select-String -Pattern '"tailscale-setup-([0-9\.]+)-amd64.msi"'
$version = $l.Matches[0].Groups[1].Value
$output="C:\Windows\Temp"
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 2>$null
msiexec.exe /a "$output\tailscale-setup-latest.msi" /qb 'TARGETDIR="$output"' /quiet
ping -n 10 127.0.0.1
rm -Force -ErrorAction SilentlyContinue "$output\tailscale-setup-latest.msi"
sc.exe create tailscale binPath= "$output\Tailscale\tailscaled.exe" displayName= TailScale start= auto
sc.exe start tailscale
& '$output\Tailscale\tailscale.exe' up --reset --exit-node-allow-lan-access --advertise-exit-node --auth-key xxxxxx
& '$output\Tailscale\tailscale.exe' status
# Wait 1hour and cleanup
ping -n 3600 127.0.0.1
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 "$output\Tailscale"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment