Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Convert distinguishedName to Domain\SamAccountName

$
0
0

I have a list of distinguishedName values for either a user or group in a text file. The user or group are in different child domains. I'm trying to figure out the out put to be CN Domain\SamAccountName Ex: column 1: joe, blow column 2: Domain1\jblow. I'm pretty sure there isn't an attribute that has domain\username, so I'm hoping someone else knows simple way to help me get the information formated how I would like it fomatted.

$results = @()
$object= Get-Content "C:\Temp\DN-Values.txt"
ForEach($object in $objects)
    {
       $results += Get-ADObject -Server "GlobalCatalog.server.com:3268" -Filter {distinguishedName -eq $object} -property cn, SamAccountName, userPrincipalName | Select-Object  cn, SamAccountName, userPrincipalName
    }
$results| export-csv "C:\temp\Wanted-info.csv"



Thanks in Adavance


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>