Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Locate machines where a specific account is present

$
0
0

I need to find all machines where there is a local account named, say, 'John' and include its group memberships (specifically if the account is a member of Administrators and/or another group we created).  I also need to know if the account's password is set to never expire.

 

Can this be done through WMI, or do I need to use the [ADSI]"WinNT" provider?

 

Should I use gwmi Win32_Useraccount and filter on the name, then pipe that to something else?

What I'm looking to get back is a list of machines where the account exists, and the account's properties and group memberships.  Returning a boolean for the group membership is what I was thinking, giving a returned record similar to:

 

Computername,User,IsAdmin,IsAuditor,PwdExpires,Disabled

Computer1,John,True,False,False,False

 

Thanks for any help,

 

J


Viewing all articles
Browse latest Browse all 10624

Trending Articles