Add Tailscale reset script for ESA/Headscale environments
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
98e703d100
commit
dd36fe4476
@@ -0,0 +1,66 @@
|
||||
# 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 state file if present
|
||||
$statePath = "C:\ProgramData\Tailscale\tailscaled.state"
|
||||
if (Test-Path $statePath) {
|
||||
Remove-Item $statePath -Force
|
||||
Write-Host "Removed tailscaled.state"
|
||||
}
|
||||
|
||||
# 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"
|
||||
}
|
||||
}
|
||||
|
||||
# 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"
|
||||
Reference in New Issue
Block a user