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

CSS Snippet to Target Phones, Tablets, and Desktops Separately

@media (min-width:20em) { /* iPhones, Androids portrait 480x320 phones */ } @media (min-width:30em) { /*…

PowerShell: How to Replace a System File – For Experimentation Purposes

# When attempting to rename a system protected file such as notepad.exe $notepadExe='C:\Windows\system32\notepad.exe' $newNotePadExe='C:\Users\rambo\Desktop\notepad.exe' rename-item…

PowerShell: Create and Edit SMB Shares

# Create SMB Share $sharePath='C:\testshare' $accessList="$env:USERDOMAIN\Domain Admins","NT AUTHORITY\Authenticated Users" $shareName=split-path $sharePath -leaf mkdir $sharePath New-SmbShare…