Поиск по этому блогу

четверг, 26 февраля 2015 г.

Usefull AD commands

How to lock computers not logged in for last 4 weeks

dsquery computer -inactive 4 -limit 500 | dsmod computer -disabled yes

How to get a list of users in the OU with PowerShell

Get-ADUser -Filter * -SearchBase "ou=filial, dc=domain, dc=local"

How to get only names:

Get-ADUser -Filter * -SearchBase "ou=filial, dc=domain, dc=local" | fl Name

To write it into a file "d:\OUuserlist.txt":

Get-ADUser -Filter * -SearchBase "ou=filial, dc=domain, dc=local"  > d:\OUuserlist.txt

How many users are in certain OU
(Get-ADUser -SearchBase "ou=APK,ou=Users,ou=Offices,dc=local,dc=my,dc=ru" -ResultSetSize $null -LDAPFilter "(&(objectClass=user))").count

Get list with all computers in AD
Get-ADComputer -Filter * -Property * | Select-Object Name,OperatingSystem,Description | Export-CSV d:\AllWindows.csv -NoTypeInformation -Encoding UTF8

useful link