I am new to powershell. I just need this script below to read input file with groups.txt and export the results with groups that are not found in Active Directory to csv.
So, this script works and if the group exists in AD, then it just displays the group, but if it is missing from AD, then I get a long error message about 5 lines per group that object is not found, etc. I just need to know what groups in excel file do not exist in Active directory.
Could you please take the error code somehow export it so it is just one line and not 5 error lines per group.
Thank you so much!!
$groups = get-content "C:\DHL\Scripts\GroupsComputersScripts\Groups.txt"
ForEach ($g in $groups)
Get-ADGroup -Identity $g -Properties name | select name