A function to list ad-groups for an client based on computername.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#requires -Version 2 -Modules ActiveDirectory <# .Synopsis Get Computergroups based on computername .DESCRIPTION Get info about the AD-groups that the computer belongs to. .EXAMPLE get-computergroups mycomputer #> function get-Computergroups { [CmdletBinding()] [Alias()] [OutputType([int])] Param ( # Param1 help description [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] $displayname ) Begin { } Process { Get-ADComputer $displayname -Properties memberof | Select-Object -Property memberof | Select-Object -ExpandProperty memberof | Get-ADGroup -Properties name | Select-Object -Property name | Format-Table -AutoSize } End { } } |