get-adgroup
1 TopicCreate CSV & HTML showing AD Group, Group Description, ManagedBy (Friendly Name)
I need some help doing a search of AD groups with the Description starting with "Admin Group*" and get the Managedby friendly name. Some groups are managed by groups and other are by user. I've tried putting together something using other script examples but, I'm able to get the data but can't figure out how to export the results to CSV & HTML. Here is what I have so far: Get-ADGroup -filter { Description -like "Admin Group*"} -Properties CN, Description, ManagedBy | Sort-Object "CN" | ForEach-Object { $GroupName = $_.CN; $Description = $_.Description; $Manager = $_.Managedby; if (!$Manager) { $Manager = 'N/A'; } Get-ADUser -Filter * -SearchBase $Manager -Properties * { $GivenName = $_.GivenName; $Surname = $_.Surname; $managerName = $GivenName, $Surname; } if (!$ManagerName) { (Get-ADGroup -Filter * -SearchBase $Manager -Properties Name) | ForEach-Object { $managerName = $_.Name; } } Write-Output $Groupname, $Description, $ManagerName} It writes the output like this though: GroupName Description ManagerName GroupName Description ManagerName GroupName Description ManagerName Etc...1.9KViews0likes3Comments