Skip to content

Instantly share code, notes, and snippets.

@tcartwright
Last active February 14, 2025 17:18
Show Gist options
  • Save tcartwright/0934d5fe9a86af3a09fe6b4ac0b4c2e4 to your computer and use it in GitHub Desktop.
Save tcartwright/0934d5fe9a86af3a09fe6b4ac0b4c2e4 to your computer and use it in GitHub Desktop.
POWERSHELL: Test SPNs and AD connectivity
Clear-Host
Write-Host "`r`nSetspn -L `$env:COMPUTERNAME`r`n" -ForegroundColor Yellow
Setspn -L $env:COMPUTERNAME
Write-Host "`r`nSetspn -L `"`$(`$env:USERDOMAIN)\`$(`$env:USERNAME)`"`r`n" -ForegroundColor Yellow
Setspn -L "$($env:USERDOMAIN)\$($env:USERNAME)"
Write-Host "`r`nTest-ComputerSecureChannel`r`n" -ForegroundColor Yellow
Test-ComputerSecureChannel
Write-Host "`r`nTest-NetConnection (`$env:LOGONSERVER -replace `"\\`", `"`")" -ForegroundColor Yellow
Test-NetConnection ($env:LOGONSERVER -replace "\\", "")
Write-Host "`r`n[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain();" -ForegroundColor Yellow
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain();
Write-Host "`r`nGet-ADComputer -Filter * | Select-Object -First 5 | Format-Table -Property Name, DNSHostName" -ForegroundColor Yellow
Get-ADComputer -Filter * | Select-Object -First 5 | Format-Table -Property Name, DNSHostName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment