Can someone point me towards the script used by PDQ Inventory to get recursive Active Directory Groups of a computer?
Can someone point me towards the script used by PDQ Inventory to get recursive Active Directory Groups of a computer?
EDIT: I've whipped this up myself. It seems to work. Here it is in case it can help someone else:
$tempUser = Read-Host "Gimme a username: "
$groupArray = @()
$tempGroups = @()
$groupArray += (get-aduser -identity $tempUser -properties memberof).memberof
While ((Compare-Object $groupArray $tempGroups).Length -ne 0)
{
$groupArray = $tempGroups
$tempGroups = @()
$tempGroups += (get-aduser -identity $tempUser -properties memberof).memberof
foreach ($group in $groupArray)
{
$tempGroups += (get-adobject -identity $group -properties memberof).memberof
}
}
$groupArray
-
I think I've come up with a script that does this. Here it is, for anyone with this same question. Hope it helps!
$tempUser = Read-Host "Gimme a username: "
$groupArray = @()
$tempGroups = @()$groupArray += (get-aduser -identity $tempUser -properties memberof).memberof
While ((Compare-Object $groupArray $tempGroups).Length -ne 0)
{
$groupArray = $tempGroups
$tempGroups = @()
$tempGroups += (get-aduser -identity $tempUser -properties memberof).memberof
foreach ($group in $groupArray)
{
$tempGroups += (get-adobject -identity $group -properties memberof).memberof
}
}$groupArray
-
Colby Bouma, thanks for that info! For some reason, I thought active directory info was gathered with PowerShell. Good to know. Yes, my goal was to get the same info with PowerShell, and I think I've come up with a script that works.
Please sign in to leave a comment.
Comments
3 comments