Powershell 命令获取AD 组信息

Poweshell 命令获取AD 组信息

Get-ADGroup -Filter * -SearchBase "ou=Distribution,ou=Groups,ou=CN,ou=Centralized,dc=automotive,dc=ald,dc=socgen" 

获取组成员:

Get-ADGroupMember -identity "GROUPNAME" -Recursive | Get-ADUser -Property DisplayName | Select Name,ObjectClass,DisplayName,SamAccountName,mail

常用属性:

SamAccountName登录名

Displayname显示名称

Department部门

Title职称

Office办公室

Officephone办公室电话

Mobile手机

Homepage

EmployeeID员工工号

Mail邮箱地址

ExtensionAttribute1自定义属性1

ExtensionAttribute2自定义属性2

ExtensionAttribute3自定义属性3

输出到文件

Get-ADGroupMember -identity "CN DL ALL USERS" -Recursive | Get-ADUser -Property DisplayName | Select Name,ObjectClass,DisplayName | out-file “d:\CN DL ALL USERS.txt”

获取AD 用户的所在的组

(get-aduser byang -properties *).memberof