Created
January 8, 2020 13:08
-
-
Save joswr1ght/c557f8627832d54458c810e43be9c055 to your computer and use it in GitHub Desktop.
Create a Collection of Files for Windows Domain Groups with User Members in Each File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-AdGroup -Filter * | % { Get-AdGroupMember $_.Name | Select-Object -ExpandProperty SamAccountName | Out-File -FilePath "$($_.Name).txt" -Encoding ASCII } |
hi please can you guide me if i need to add also GroupCategory beside SamAccountName?
Thank you
Dealing with some big groups... ran into this error: Get-AdGroupMember : The size limit for this request was exceeded
Looks like there's a cap on size for Get-AdGroupMember and a few other ADWS cmdlets, but Get-AdUser is excluded from that. Tweaked the script. It'll do the same thing but doesn't care about size. Mind you, this will be quite a bit slower as it's not the pinnacle of efficiency.
Get-AdGroup -Filter * | % { Get-ADUser -LDAPFilter ("(&(objectCategory=user)(memberof={0}))" -f $.DistinguishedName) | Select-Object -ExpandProperty SamAccountName | Out-File -FilePath "$($.Name).txt" -Encoding ASCII }
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GCI -Path "C:\temp" | Where-Object {$_.Length -eq 0} |Remove-Item
- Remove 0-byte files