Hello -
I am a very new user (have only known about Powershell for a couple of weeks) and have cobbled together the below script to pull information about all the Groups in AD. The script works great except I would really like some help to be able to add a column to the export which includes the groupType (I need to differentiate bewteen global/local/universal security and distribution groups). Please keep in mind I do not have access to the Active Directory Module.
Thank you
$Outfile = C:\Grouplist.csv
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objOU = New-Object System.DirectoryServices.DirectoryEntry("LDAP://OU=Groups,DC=AAA,DC=BBB,DC=COM")
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objOU
$objSearcher.PageSize = 1000
$objSearcher.SearchScope = "Subtree"
$colResults = $objSearcher.FindAll()
$objCollection = $colResults | select -Expand Properties |
select @{n='Name';e={$_.name}}, @{n='DisplayName';e={$_.displayname}}, @{n='samaccountName';e={$_.samaccountname}}, @{n='email';e={$_.mail}}, @{n='whencreated';e={$_.whencreated}}, @{n='objectcategory';e={$_.objectcategory}}, @{n='description';e={$_.description}}, @{n='info';e={$_.info}}, @{n='memberof';e={$_.memberof -replace '^cn=([^,]+).+$','$1' -join ";"}}
$objCollection | export-csv -Path $Outfile -Notype