MilesLogan
asked on
Get AD Group Member details
Hi EE
I have the script below that will pull AD group member information from the groups entered in the txt file . Can someone help me modify it so it prompts me for the group name?
Import-Module Activedirectory
[array]$Members=$null
GC groups.txt | % {
$Group = Get-ADGroup $_ -ErrorAction SilentlyContinue
If ($Group){
$members += Get-ADGroup $Group.Name -Properties Members |
Select-Object -ExpandProperty Members |
Get-ADObject -properties Samaccountname |
?{$_.ObjectClass -eq "user"} | Get-aduser -Properties * |
Select @{L='GroupName';e={$Group. Name}},Nam e,Samaccou ntname,mai l
}
}
$Members | Select * | Export-Csv GroupDetails_$((Get-Date -Format MM-dd-yyyy)).csv -NoTypeInformation
I have the script below that will pull AD group member information from the groups entered in the txt file . Can someone help me modify it so it prompts me for the group name?
Import-Module Activedirectory
[array]$Members=$null
GC groups.txt | % {
$Group = Get-ADGroup $_ -ErrorAction SilentlyContinue
If ($Group){
$members += Get-ADGroup $Group.Name -Properties Members |
Select-Object -ExpandProperty Members |
Get-ADObject -properties Samaccountname |
?{$_.ObjectClass -eq "user"} | Get-aduser -Properties * |
Select @{L='GroupName';e={$Group.
}
}
$Members | Select * | Export-Csv GroupDetails_$((Get-Date -Format MM-dd-yyyy)).csv -NoTypeInformation
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER