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

Function to Import PortQry (a Systernal Utility)

Update: much adieu about nothing. Run this quick script and ignore the prior jibberish: if…

PowerShell: Create New Hybrid On Prem Active Directory User with Office 365 Integration

# createNewHybridUser_v0.0.1.ps1# .Description: this script automates the creation of a user account in a hybrid…

How To Automate Youtube Full Screen on Ubuntu Using Python & Selenium

#sudo apt install python3 python3-pip #sudo pip3 install selenium #pip install webdriver-manager # Variables YoutubeUrl="https://www.youtube.com/watch?v=7nT5YawZt-s"…