Terellion
asked on
Retrieve Local Admins via Powershell
Hey guys, i'd like a script to run to retrieve the list of local Administrators of a group of servers but only match certain users.
So something like
(Get-WMIObject Win32_Group | Where-Object { $_.Name –eq ‘Administrators’ }).GetRelated() | Where-Object { $_.__CLASS –eq “Win32_UserAccount” –or $_.__CLASS –eq “Win32_Group” } | Select-Object __CLASS,Caption,SID
But have a where-object that includes a certain user (just so we can identify if a user has local admin to any server.
Thanks for your help :)
So something like
(Get-WMIObject Win32_Group | Where-Object { $_.Name –eq ‘Administrators’ }).GetRelated() | Where-Object { $_.__CLASS –eq “Win32_UserAccount” –or $_.__CLASS –eq “Win32_Group” } | Select-Object __CLASS,Caption,SID
But have a where-object that includes a certain user (just so we can identify if a user has local admin to any server.
Thanks for your help :)
ASKER
Hi there, thanks for that. Do you know how to filter this down though so it only shows certain users?
Hi
Check out the forum
http://stackoverflow.com/questions/4548476/powershell-list-local-users-and-their-groups
Thanks & Regards
Dexter
Check out the forum
http://stackoverflow.com/questions/4548476/powershell-list-local-users-and-their-groups
Thanks & Regards
Dexter
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Subsun, thats brilliant! Is there a way to only show the ones that say Member - Yes? Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is absolutely superb, works a treat THANK YOU! :)
Follow the link for script to retrive local admins
http://andrewmorgan.ie/2011/06/retrieve-a-list-of-local-administrators-using-powershell/
Thanks
Dexter