im quite new powershell , i've hit brickwall finding information csv. have ad group of users , im trying find entries include samaccountname csv.
the csv has headings samaccountname, ip, subnet , hostname. example here extract: neilp,10.1.52.22,10.1.52.0,hostname01
i need find hostnames of samaccountnames in csv in ad group.
i've been trying compare-object cmdlet have had no success:
import-module activedirectory $test_users = get-adgroupmember test_users $data = import-csv .\data.csv $data | foreach-object {compare-object $_ $test_users-excludedifferent } can help?
try this:
import-module activedirectory $test_users = get-adgroupmember test_users $data = import-csv .\data.csv compare-object $data $test_users -prop samaccountname -include -exclude | % { $account = $_.samaccountname $data | ? { $_.samaccountname -eq $account } | % { $_.hostname } }
Comments
Post a Comment