Link to home
Start Free TrialLog in
Avatar of sqlagent007
sqlagent007Flag for United States of America

asked on

powershell - is there an easy way to query AD for a SPN -like '*my-sql-instance*'?

I am trying to add a check for the SPN in our SQL review script. I will have the ability to build a variable with the SQL server name instance name.

When I use CMD > setspn -L DOMAIN\USER I get a list that I can search and see if the SPN has been created or not.

There must be a way I can use powershell to get that list, then search the list for a string value.

Just to be specific, I am looking for a way to use powershell to query Active Directory for a value LIKE 'my-sql-intance' name. I just need to return SPNs that look like they match the string value.
ASKER CERTIFIED SOLUTION
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sqlagent007

ASKER

Get-ADComputer -Identity "Your_Server_Name_Here" -Properties ServicePrincipalNames |Select-Object -ExpandProperty ServicePrincipalNames

Open in new window


I had to install and import the "get-ad" modules, but then it worked like a champ.
thanks