Get AD groups, members and Authorig

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
Reddrgn2
Posts: 36
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Wed May 23, 2018 6:13 am

Get AD groups, members and Authorig

Post by Reddrgn2 »

Product, version and build:
64 b - primalscript 2020 - version 7.7.139
Operating system:
64 bit OS: win 10 enterprise

I am looking for a way to get Ad groups, its members (name), Authorig (users that have the ability to send to group) and export results. Here is what I am going with. It gets the group, user name but having issues with getting the authorig. I am thinking it won't really work due the way I going about getting the groups and members. I tried to re-think the way to go about getting the info. Anyone got thoughts on how to go about this?
  1. $Groups = Get-ADGroup -Filter * -SearchBase 'OU=,DC=,DC=' -Properties Name, members, authorig
  2.  
  3. $Results = foreach( $Group in $Groups ){
  4.  
  5.     Get-ADGroupMember -Identity $Group | ForEach-Object {
  6.  
  7.         [pscustomobject]@{
  8.  
  9.             GroupName = $Group.Name
  10.  
  11.             Name = $_.Name
  12.  
  13.             authorig = $_.authorig
  14.  
  15.             }}}
  16.  
  17. $Results | Export-Csv E:\Exports\test8.$((Get-Date).ToString('MM.dd.yy')).csv -NoTypeInformation

User avatar
Alexander Riedel
Posts: 7343
Joined: Tue May 29, 2007 4:43 pm

Re: Get AD groups, members and Authorig

Post by Alexander Riedel »

[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.

jvierra
Posts: 14358
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Get AD groups, members and Authorig

Post by jvierra »

To get attributes of a user you need to use Get-AdUser. I have no idea what authorig is as it is not an attribute of any object in AD. Is it a schema addition?

Code: Select all

Get-ADGroup -Filter * -SearchBase 'OU=,DC=,DC=' -PipelineVariable grp |
    Get-ADGroupMember  |
    Where-Object{$_.objectClass -eq 'User'} |
    Get_Aduser -Properties authorig|
    Select-Object @{n='GroupName';e={$grp.Name}},Name,authorig

User avatar
Reddrgn2
Posts: 36
Joined: Wed May 23, 2018 6:13 am

Re: Get AD groups, members and Authorig

Post by Reddrgn2 »

I can't get this to run, it is having issues with "identity"

ERROR: Get-ADGroupMember : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Provide an argument that is not null or empty, and then
ERROR: try the command again
ERROR: + Get-ADGroupMember -Identity $Group |
ERROR: + ~~~~~~
ERROR: + CategoryInfo : InvalidData: (:) [Get-ADGroupMember], ParameterBindingValidationException
ERROR: + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.GetADGroupMember
ERROR:

jvierra
Posts: 14358
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Get AD groups, members and Authorig

Post by jvierra »

Sorry - I forgot to delete that before posting. Copy again and you won't get that message.

User avatar
Reddrgn2
Posts: 36
Joined: Wed May 23, 2018 6:13 am

Re: Get AD groups, members and Authorig

Post by Reddrgn2 »

It worked sort of. I ran into issue with multiple values for the authorig.

jvierra
Posts: 14358
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Get AD groups, members and Authorig

Post by jvierra »

You will have to use "join" to cattenate the values.

User avatar
Reddrgn2
Posts: 36
Joined: Wed May 23, 2018 6:13 am

Re: Get AD groups, members and Authorig

Post by Reddrgn2 »

I haven't done that before, looking at it now

jimbaker
Posts: 1
Joined: Fri Apr 17, 2020 9:44 am

Re: Get AD groups, members and Authorig

Post by jimbaker »

Hmm, that's a pretty interesting one. I need to think about that. I hope I will be able to help you with that.

Locked