Hi all
I'm trying to extract the FQDN of the domain from an AD object's DN
So I've got a an excel file with a list of DN as below:
CN=* Lastname\, * Firstname * 1st,OU=3rd Party ,OU=PBBI,OU=Offshore,DC=contoso,DC=com for example.
I've figured out a method but I'm struggling to actually implement it in powershell
My idea is as follows:
1.) Locate the first instance of "DC=" in the string
2.) Cut out the substring from the DC= until the end of the string
3.) Break the resulting substring up into domain names by splitting it at the semi colons eg
dc=contoso,dc=com becomes $namenode1 = contoso $namenode = com and then I combine them so the resultant string is contoso.com and I add that to the last column in the row.
Can anyone provide some guidance or some code samples to assist as I'm a bit stumped.
Thanks in advance