From 2a64e332d9a39cc98183220595446e111220af4c Mon Sep 17 00:00:00 2001 From: Gabe Date: Tue, 5 Aug 2025 14:52:08 +0000 Subject: [PATCH] Upload files to "AD Scripts" --- AD Scripts/Get AD users and their group memberships.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 AD Scripts/Get AD users and their group memberships.ps1 diff --git a/AD Scripts/Get AD users and their group memberships.ps1 b/AD Scripts/Get AD users and their group memberships.ps1 new file mode 100644 index 0000000..9c794e1 --- /dev/null +++ b/AD Scripts/Get AD users and their group memberships.ps1 @@ -0,0 +1,9 @@ +Get-ADUser -Filter * -Properties SamAccountname, DisplayName | ForEach-Object { + New-Object PSObject -Property @{ + UserName = $_.DisplayName + oSamAccountname = $_.SamAccountname + UserOU = ($_.DistinguishedName -split ",",2)[1] + Groups = (Get-ADPrincipalGroupMembership $_.SamAccountname | Select-Object -ExpandProperty Name) -join + "," + } +} | Select-Object oSamAccountname, UserName, UserOU, Groups | Export-Csv -Path "C:\Temp\Script Cache\Audit\ADUserandGroupMembers.csv" -NoTypeInformation \ No newline at end of file