Powershell instance domain controller (collected)

1, the query AD, the default password policy
Get-ADDefaultDomainPasswordPolicy

  1. AD query, the user who selected the "Password never expires" in selected top
    Get-ADUser -Filter 'PasswordNeverExpires -eq $ true' -Server DCHostname | select name
    if only refer to a query under the OU, you can add qualifications :
    -SearchBase 'the OU = Test, = Youdomain the DC, the DC = the COM'

3. AD query, the user has locked the
GET-ADUser -filter -properties | {.} $ _ LockedOut WHERE |. Ft name, LockedOut

4. Query AD, the member is empty AD groups (for the user)
the Get-ADGroup the -Filter * and -Properties, which Members | -not $ _ {WHERE Members.} | SELECT the Name

The user unlocks the locked
Unlock-ADAccount -Identity xxxxxx

6. find out if a user locks
get-aduser test -properties * | ft name, lockedout

7. Repair damaged trust between the client and the domain
input cmdlet:
the Test-ComputerSecureChannel -Server "controller.domain.com"

OU query is not registered in AD account all month:
the PS C: \ the Users \ Administrator> the Get-ADUser -SearchBase '= rightdo the DC, the DC = NET' -filter and -Properties, which | the Select Object-the Name, the SID, the Created, PasswordLastSet , n-{@ = "lastLogonDate"; E = {[datetime] :: FromFileTime ($ .lastLogonTimestamp)}} | $ {WHERE .lastlogondate -LT-(GET-DATE) .AddDays (-30)}

Query OU created in time for all accounts \ SID \ password last modified time \ last login time
the Get-ADUser -SearchBase '= rightdo DC, DC = NET' -filter -Properties | the Select-Object the Name, SID, the Created, PasswordLastSet , @ {n = "lastLogonDate" ; e = {[datetime] :: FromFileTime ($ _ lastLogonTimestamp.)}}

首先导出csv文件
Get-ADUser -Filter -Properties | where {$_.UserPrincipalName -ne $null} | Select-Object SamAccountName,EmployeeID,EmployeeType,description | Export-Csv -Encoding Utf8 -NoTypeInformation c:\aduserinfo.csv

Modify the exported user information is updated after the
Import-Csv -Path c:. \ Aduserinfo.csv | {foreach the Set-ADUser -Identity $ SamAccountName -EmployeeID $ .EmployeeID
the -replace EmployeeType = @ {$ .EmployeeType; the Description = $ .description }}

Guess you like

Origin blog.51cto.com/907832555/2449557