Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, January 8, 2014 12:16 AM
I'm looking for a PowerShell script that will query and output all the local and AD users, service accounts, and groups on a given Windows servers. I need the script to recursively list the members of each group that has privileges on that server. I'm looking for a script that will give me a good starting point from which I can tailor it to my specific needs. Thanks.
All replies (4)
Wednesday, January 8, 2014 2:03 AM ✅Answered | 1 vote
Hi,
Have you looked through the repository?
http://gallery.technet.microsoft.com/scriptcenter
Don't retire TechNet! - (Don't give up yet - 12,575+ strong and growing)
Wednesday, January 8, 2014 8:03 AM ✅Answered | 1 vote
Hi Teancum144,
Agree with Mike, the link above can provide plenty of great powershell script resources.
In addition, if you want to list all local users and groups, the script below may be helpful for you:
$server = "servername"
$computer = [ADSI]"WinNT://$server,computer"
$computer.psbase.children | where { $_.psbase.schemaClassName -eq 'group' } | foreach {
write-host $_.name
write-host ""
$group =[ADSI]$_.psbase.Path
$group.psbase.Invoke("Members") | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
write-host
}
I hope this helps.
Friday, January 10, 2014 3:52 PM ✅Answered
Mike and AnnaWY, thanks for your feedback, here are some additional resources that I found useful:
- http://serverfault.com/questions/565808/powershell-script-to-list-a-servers-users-groups-permissions-etc/566185#566185
- http://poshcode.org/544
Friday, January 10, 2014 3:57 PM | 1 vote
Cheers, hopefully you've found a good starting point for yourself. Here's another good resource for group auditing:
http://www.rlmueller.net/freecode3.htm
Some are VBScript, some are PowerShell.
Don't retire TechNet! - (Don't give up yet - 12,575+ strong and growing)