标题: [转载代码] [PowerShell每日技巧]查看本地组里面有哪些用户(20131220) [打印本页]
作者: DAIC 时间: 2013-12-30 13:15 标题: [PowerShell每日技巧]查看本地组里面有哪些用户(20131220)
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
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |