The cmdlet you should be using is Get-ADGroupMember.
The Get-ADPrincipalGroupMembership will get you the groups in which an AD object is a member.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
HI guys, maybe you can help me with this question, i need to get a list of computer inside an especific group in the active directory, but none of the scripts i've tried, work.
Example:
Get-ADPrincipalGroupMembership -Identity "GRP_NAC_POLITICAS" | export-csv 'C:\Users\svc1yol\Documents\grupitos.csv'
i execute it, and nothing happen.
id be really thankful if anybody can help me.
The cmdlet you should be using is Get-ADGroupMember.
The Get-ADPrincipalGroupMembership will get you the groups in which an AD object is a member.
If you only want computers, you can include a client side filter against the objectClass
Get-ADGroupMember testGroup | Where-Object {$_.objectClass -eq 'Computer'}
Hi there,
The below script might help you in exporting the data to excel.
Get-ADComputer -Filter * -Properties * | Where-Object {
$.MemberOf -like "*SOME OF THE GROUP NAME*"
} | Select-Object Name,OperatingSystem,@{
N="Grupper";E={
$groups=""
$.MemberOf | get-adgroup | Select-Object Name | ForEach-Object {$groups+=$_.Name+","}
$groups -replace ",$",""
}
} | Export-csv "C:\temp\file.csv"
--If the reply is helpful, please Upvote and Accept it as an answer--