Can someone point me towards the script used by PDQ Inventory to get recursive Active Directory Groups of a computer?

Comments

3 comments

  • Colby Bouma

    If you're referring to one of Inventory's built-in scanners, those are written in C#, not PowerShell.

    Are you looking to pull the same information without using Inventory?

    0
    Comment actions Permalink
  • Joe Wiard

    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

    0
    Comment actions Permalink
  • Joe Wiard

    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.

    0
    Comment actions Permalink

Please sign in to leave a comment.