# PowerShell Script to Reset Tailscale on Windows # Works even if Tailscale service is not present function Get-TailscalePath { $pathsToCheck = @( "$env:ProgramFiles\Tailscale\tailscale.exe", "${env:ProgramFiles(x86)}\Tailscale\tailscale.exe", "$env:LOCALAPPDATA\Tailscale\tailscale.exe" ) foreach ($path in $pathsToCheck) { if (Test-Path $path) { return $path } } return $null } $tailscalePath = Get-TailscalePath if (-not $tailscalePath) { Write-Warning "Tailscale CLI not found on this system. Skipping CLI commands..." } else { Write-Host "Found Tailscale CLI at $tailscalePath" & "$tailscalePath" logout } # Stop service if exists $service = Get-Service -Name "Tailscale" -ErrorAction SilentlyContinue if ($service) { Write-Host "Stopping Tailscale service..." Stop-Service Tailscale -Force } else { Write-Warning "Tailscale service not found, skipping stop." } # Remove ProgramData folder if present $programDataPath = "C:\ProgramData\Tailscale" if (Test-Path $programDataPath) { Remove-Item $programDataPath -Recurse -Force Write-Host "Removed folder: $programDataPath" } # Remove appdata folders $localApp = "$env:LOCALAPPDATA\Tailscale" $roamingApp = "$env:APPDATA\Tailscale" foreach ($folder in @($localApp, $roamingApp)) { if (Test-Path $folder) { Remove-Item $folder -Recurse -Force Write-Host "Removed folder: $folder" } } # Set Headscale registry configuration $registryPath = 'HKLM:\Software\Tailscale IPN' New-Item -Path $registryPath -Force | Out-Null New-ItemProperty -Path $registryPath -Name UnattendedMode -PropertyType String -Value "user-decides" -Force | Out-Null New-ItemProperty -Path $registryPath -Name AllowIncomingConnections -PropertyType String -Value "never" -Force | Out-Null New-ItemProperty -Path $registryPath -Name AdminConsole -PropertyType String -Value "hide" -Force | Out-Null New-ItemProperty -Path $registryPath -Name NetworkDevices -PropertyType String -Value "hide" -Force | Out-Null New-ItemProperty -Path $registryPath -Name TestMenu -PropertyType String -Value "hide" -Force | Out-Null New-ItemProperty -Path $registryPath -Name LoginURL -PropertyType String -Value "http://headscale.estudiogroup.com:8080" -Force | Out-Null Write-Host "Registry keys created successfully." # Restart service if exists if ($service) { Start-Service Tailscale Write-Host "Restarted Tailscale service" } # Show prefs if CLI was found if ($tailscalePath) { & "$tailscalePath" debug prefs } Write-Host "`n✅ Tailscale reset complete. If you're using Headscale, run:" Write-Host "`ttailscale up --login-server http://headscale.estudiogroup.com:8080"