Author Posts

September 11, 2018 at 7:24 pm

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 -properties servicePrincipalName |
    Set-ADUser -Clear = @{'servicePrincipalName'=$_.servicePrincipalName}

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

September 11, 2018 at 7:48 pm

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

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

September 11, 2018 at 8:38 pm

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 -Credential $creds -Identity $_.server -properties servicePrincipalName | 
    Set-ADComputer -Clear servicePrincipalName}

..and it works. Thanks for looking.