Posted On March 11, 2021

PowerShell: Dealing with Service Principle Names (SPNs)

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Dealing with Service Principle Names (SPNs)

Basic Commands:

# Show SPNs
$computername="$env:computername"
Get-ADComputer -Identity $computername -Properties ServicePrincipalNames |Select-Object -ExpandProperty ServicePrincipalNames

# Add one SPN
Set-ADComputer @{Add="WSMAN/$computername"}

# Add multiple SPNs
Set-ADComputer -ServicePrincipalNames @{Add='WSMAN/Mycomputer',"WSMAN/$computername.$env:USERDNSDOMAIN"}

# Edit SPNs
Set-ADComputer -ServicePrincipalNames @{Add='WSMAN/Mycomputer'},@{Remove="WSMAN/$computername.$env:USERDNSDOMAIN"}

# Clear SPNs
# Set-ADComputer -ServicePrincipalNames $Null

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Start-Job, Get-Job, Receive-Job Examples

Demo 1: Obtain Public IP of a Windows Machine # Commands to run locally$command1={(Invoke-WebRequest -URI…

PowerShell: Raise Domain Forest Functional Level

# Raise Forest Functional Level$forest=Get-ADForest# 2012R2 LevelSet-ADForestMode -Identity $forest -Server $forest.SchemaMaster -ForestMode Windows2012R2Forest -Force# 2016…

Linux: GREP Training

Lorum Ipsum - let's learn about grep, ya'll Examples: # Get information only on the…