Get AD groups, members and Authorig

Ask your 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.
This topic is 3 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Reddrgn2
Posts: 49
Last visit: Wed Nov 08, 2023 10:34 am
Answers: 1

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. $Results = foreach( $Group in $Groups ){
  3.     Get-ADGroupMember -Identity $Group | ForEach-Object {
  4.         [pscustomobject]@{
  5.             GroupName = $Group.Name
  6.             Name = $_.Name
  7.             authorig = $_.authorig
  8.             }}}
  9. $Results | Export-Csv E:\Exports\test8.$((Get-Date).ToString('MM.dd.yy')).csv -NoTypeInformation
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Get AD groups, members and Authorig

Post by Alexander Riedel »

[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 49
Last visit: Wed Nov 08, 2023 10:34 am
Answers: 1

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 49
Last visit: Wed Nov 08, 2023 10:34 am
Answers: 1

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get AD groups, members and Authorig

Post by jvierra »

You will have to use "join" to cattenate the values.
User avatar
Reddrgn2
Posts: 49
Last visit: Wed Nov 08, 2023 10:34 am
Answers: 1

Re: Get AD groups, members and Authorig

Post by Reddrgn2 »

I haven't done that before, looking at it now
jimbaker
Posts: 1
Last visit: Mon Apr 20, 2020 2:15 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.
This topic is 3 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked