Ниже скрипт на PowerShell. Запуск с повышением прав
clear
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = "LDAP://dc=gladspir,dc=ru"
$objSearcher.Filter = "(&(objectCategory=person)(!userAccountControl:1.2.840.113556.1.4.803:=2))"
$users = $objSearcher.FindAll()
# Количество учетных записей
$users.Count
$users | ForEach-Object {
$user = $_.Properties
New-Object PsObject -Property @{
Должность = [string]$user.description
Отдел = [string]$user.department
Логин = [string]$user.userprincipalname
Телефон = [string]$user.telephonenumber
MТелефон = [string]$user.mobile
Комната = [string]$user.physicaldeliveryofficename
ФИО = [string]$user.cn
ФАМ = [string]$user.sn
ИМЯ = [string]$user.givenname
ГОРОД = [string]$user.l
МЫЛО = [string]$user.mail
РасположениеАД = ([string]$user.distinguishedname).Substring( `
([string]$user.distinguishedname).IndexOf("OU") `
, `
([string]$user.distinguishedname).Length - ([string]$user.distinguishedname).IndexOf("OU"))
ПоследнийВход = [datetime]::FromFileTime([string]$user.lastlogon).ToString('g')
}
} | Export-Csv -NoClobber -Encoding Unicode -Path C:\export\list_users_act.csv
clear
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = "LDAP://dc=gladspir,dc=ru"
$objSearcher.Filter = "(&(objectCategory=person)(!userAccountControl:1.2.840.113556.1.4.803:=2))"
$users = $objSearcher.FindAll()
# Количество учетных записей
$users.Count
$users | ForEach-Object {
$user = $_.Properties
New-Object PsObject -Property @{
Должность = [string]$user.description
Отдел = [string]$user.department
Логин = [string]$user.userprincipalname
Телефон = [string]$user.telephonenumber
MТелефон = [string]$user.mobile
Комната = [string]$user.physicaldeliveryofficename
ФИО = [string]$user.cn
ФАМ = [string]$user.sn
ИМЯ = [string]$user.givenname
ГОРОД = [string]$user.l
МЫЛО = [string]$user.mail
РасположениеАД = ([string]$user.distinguishedname).Substring( `
([string]$user.distinguishedname).IndexOf("OU") `
, `
([string]$user.distinguishedname).Length - ([string]$user.distinguishedname).IndexOf("OU"))
ПоследнийВход = [datetime]::FromFileTime([string]$user.lastlogon).ToString('g')
}
} | Export-Csv -NoClobber -Encoding Unicode -Path C:\export\list_users_act.csv
Комментариев нет:
Отправить комментарий