Script for finding a list of distinguished AD names?

How would one or create a PS script that could find LDAP Distinguished Names by using a filter? For instance pulling names like below?I have a list of the Application groups in their generic format without the CN/distinguished name. I would also need to them to be exported to a .CSV.

CN=Application.SnowFlake.Prod.CAO_TECH.BRAND_PROTECTION.READ,OU=Portal,DC=ad,DC=blank,DC=com

I would think get-adgroup-Filter * % {$_DistinguishedName.split. (“,”) or something similar would work?

 

Thanks

You cannot filter on DistinguishedName, it’s derived at runtime. If you just have the names, you would do something like this (not tested):

#$csv = Import-Csv -Path C:\mycsv

#Emulate CSV import
$csv = @"
GroupName
ApplicationGroup1
ApplicationGroup2
ApplicationGroup3
"@ | ConvertFrom-Csv

$results = foreach ($group in $csv) {
    Get-ADGroup -Identity $group.GroupName
}

$results #| Export-Csv -Path C:\MyResults.csv -NoTypeInformation
$Group="Group1
Group2
Group3" -split "\r\n"

$Group | Get-ADGroup