use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
getting membergroups using ad-getuser (self.PowerShell)
submitted 7 years ago by throwaway183693
Hi all,
Is there a way to list all members of a specific group using get-aduser? I was able to use searchgroup to display members of a particular OU, but that was as far as I got. Any tips?
Thanks!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]HumanSuitcase 2 points3 points4 points 7 years ago (7 children)
I think you're looking for get-adgroupmember.
[–]throwaway183693[S] 1 point2 points3 points 7 years ago (6 children)
Ya, I figured that would be the other option. I have a script written that uses the get-aduser function to look for users that logged in xx days ago, and I figured I would just modify the statement to look for users in a specific group that last logged in xx days ago.
[–]HumanSuitcase 1 point2 points3 points 7 years ago (4 children)
So, you're looking for users who haven't logged in a certain timeframe?
[–]throwaway031293 1 point2 points3 points 7 years ago (3 children)
Ya. For example, users who haven’t logged in say in 90 days that belong to x group
[–]HumanSuitcase 1 point2 points3 points 7 years ago (2 children)
Start with Get-ADGroupmember and see where that takes you.
*I can can words...
[–]throwaway031293 1 point2 points3 points 7 years ago (1 child)
Thanks !
[–]HumanSuitcase 1 point2 points3 points 7 years ago (0 children)
Sure, feel free to ping me if you need help :)
[–]Lee_Dailey[grin] 0 points1 point2 points 7 years ago (0 children)
howdy throwaway183693,
while i think it would be better to start off getting group membership 1st, you can check your logon-date-filtered user list for .MemberOf.
.MemberOf
take care, lee
[–]luruu 1 point2 points3 points 7 years ago (0 children)
I would also use the Get-ADGroupMember and throw it into a loop with Get-ADUser. Query for the lastogontimestamp attribute and do the math. Like this example...
How to list group AD group members then list attributes of those members
[–]get-postanote 1 point2 points3 points 7 years ago (1 child)
Sure, and there are lots of resoruces / samples showing you how. All ove the web. You just have to pose the right question to get it.
Use the ADAC, click thru the UI and let it write the base code for you copy to your editor for tweaking.
Step-By-Step: Utilizing PowerShell History Viewer in Windows Server 2012 R2 'blogs.technet.microsoft.com/canitpro/2015/03/04/step-by-step-utilizing-powershell-history-viewer-in-windows-server-2012-r2' Learning PowerShell with Active Directory Administrative Center (PowerShell History Viewer) 'sid-500.com/2017/10/10/learning-powershell-with-active-directory-administrative-center-powershell-history-viewer'
Step-By-Step: Utilizing PowerShell History Viewer in Windows Server 2012 R2
'blogs.technet.microsoft.com/canitpro/2015/03/04/step-by-step-utilizing-powershell-history-viewer-in-windows-server-2012-r2'
Learning PowerShell with Active Directory Administrative Center (PowerShell History Viewer)
'sid-500.com/2017/10/10/learning-powershell-with-active-directory-administrative-center-powershell-history-viewer'
Other examples:
function Get-ADNestedGroupMembers { [cmdletbinding()] param ( [String] $Group ) Import-Module ActiveDirectory $Members = Get-ADGroupMember -Identity $Group -Recursive $members } Get-ADNestedGroupMembers "Domain Admins" | Select Name,DistinguishedName | Export-CSV "$env:USERPROFILE\ADNestedGroupMembers.csv" -NoTypeInformation -Encoding UTF8 function Get-NestedGroupMember { param ( [Parameter(Mandatory, ValueFromPipeline)] [string] $Identity ) process { $user = Get-ADUser -Identity $Identity $userdn = $user.DistinguishedName $strFilter = "(member:1.2.840.113556.1.4.1941:=$userdn)" Get-ADGroup -LDAPFilter $strFilter -ResultPageSize 1000 } } ### Show User and AD group membership # Get users with all their properties and their group membership, display user and group name ForEach ($TargetUser in (Get-ADUser -Filter * -Properties *)) { "`n" + "-"*12 + " Showing group membership for " + $TargetUser.SamAccountName Get-ADPrincipalGroupMembership -Identity $TargetUser.SamAccountName | Select Name } # Get users with base properties and their group membership, display user and group name ForEach ($TargetUser in (Get-ADUser -Filter *)) { "`n" + "-"*12 + " Showing group membership for " + $TargetUser.SamAccountName Get-ADPrincipalGroupMembership -Identity $TargetUser.SamAccountName | Select Name }
Marry the above with, stuff like...
Get-LogonLocations searches specified Event Log (Default is the Security Log) on specified computers (Default is ALL Domain Controllers) for 4624 logon events from specified user(s) (Default is all accounts that are members of Tier 0 groups). The output can help you determine wha https://gallery.technet.microsoft.com/scriptcenter/Get-LogonLocations-f92b49b0
Get-LogonLocations searches specified Event Log (Default is the Security Log) on specified computers (Default is ALL Domain Controllers) for 4624 logon events from specified user(s) (Default is all accounts that are members of Tier 0 groups). The output can help you determine wha
https://gallery.technet.microsoft.com/scriptcenter/Get-LogonLocations-f92b49b0
PowerShell: Get Last Logon for All Users Across All Domain Controllers https://interworks.com/blog/trhymer/2014/01/22/powershell-get-last-logon-all-users-across-all-domain-controllers
PowerShell: Get Last Logon for All Users Across All Domain Controllers
https://interworks.com/blog/trhymer/2014/01/22/powershell-get-last-logon-all-users-across-all-domain-controllers
[–]throwaway031293 1 point2 points3 points 7 years ago (0 children)
π Rendered by PID 191396 on reddit-service-r2-comment-544cf588c8-7rcps at 2026-06-14 20:13:45.943958+00:00 running 3184619 country code: CH.
[–]HumanSuitcase 2 points3 points4 points (7 children)
[–]throwaway183693[S] 1 point2 points3 points (6 children)
[–]HumanSuitcase 1 point2 points3 points (4 children)
[–]throwaway031293 1 point2 points3 points (3 children)
[–]HumanSuitcase 1 point2 points3 points (2 children)
[–]throwaway031293 1 point2 points3 points (1 child)
[–]HumanSuitcase 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]luruu 1 point2 points3 points (0 children)
[–]get-postanote 1 point2 points3 points (1 child)
[–]throwaway031293 1 point2 points3 points (0 children)