In PowerShell, local accounts and groups can be managed in an object-oriented way thanks to .NET Framework 3.51 and above. This will list local administrator accounts:- Add-Type -AssemblyName System.DirectoryServices.AccountManagement
-
- $type = New-Object DirectoryServices.AccountManagement.PrincipalContext('Machine', `
- $env:COMPUTERNAME)
-
- $group = [DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity($type, `
- 'SAMAccountName', 'Administrators')
-
- $group.Members | Select-Object -Property SAMAccountName, LastPasswordSet, LastLogon, Enabled
复制代码 You can get a lot more, though. Try and query the group by itself:复制代码 Or try and view all properties for all members:复制代码 http://powershell.com/cs/blogs/tips/archive/2013/12/20/getting-local-group-members.aspx |