Clear SPN attribute from list of Servers

Welcome Forums General PowerShell Q&A Clear SPN attribute from list of Servers

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 months ago.

  • Author
    Posts
  • #111605

    Participant
    Points: 71
    Rank: Member

    I have this code to clear the SPN from a text list of servers in our AD

    get-content C:\temp\migration\servers.txt | % {Get-ADComputer -Identity $_ -Server corp.com -properties servicePrincipalName |
        Set-ADUser -Clear = @{'servicePrincipalName'=$_.servicePrincipalName}

    ...Does this look correct? If not, can you help adjust this script please?

  • #111610

    Participant
    Points: 861
    Helping Hand
    Rank: Major Contributor

    Is this a typo or this is how your code looks like ?

     Set-ADUser -Clear = @{'ServicePrinicpalName'=$_.ServicePrinicpalName}
    • #111613

      Participant
      Points: 71
      Rank: Member

      was a typo, thanks, corrected, but I see I was using Set-ADUser not Set-ADComputer (!)

      I revised with this:

      $creds = Get-Credential
      Import-Csv .\servers.csv | % {Get-ADComputer -Server corp.com -Credential $creds -Identity $_.server -properties servicePrincipalName | 
          Set-ADComputer -Clear servicePrincipalName}

      ..and it works. Thanks for looking.

The topic ‘Clear SPN attribute from list of Servers’ is closed to new replies.