酷云的csdn 2019-11-12
3.查询AD中,已锁定的用户
get-aduser -filter -properties | where {$_.lockedout} | ft name,lockedout
4.查询AD中,成员为空AD组(针对用户)
Get-ADGroup -Filter * -Properties Members | where { -not $_.Members} | select Name
5.对锁定的用户进行解锁
Unlock-ADAccount -Identity xxxxxx
6.查询某个用户是否锁定
get-aduser test -properties * | ft name,lockedout
7.修复客户端和域之间的信任损坏
输入cmdlet:
Test-ComputerSecureChannel -Server“controller.domain.com”
查询OU中所有一个月内未登录的AD帐号:
PS C:\Users\administrator>Get-ADuser -searchbase ‘ DC=rightdo,DC=net ‘ -filter -Properties | Select-Object Name,SID, Created,PasswordLastSet,@{n="lastLogonDate";e={[datetime]::FromFileTime($.lastLogonTimestamp)}} | where {$.lastlogondate -lt (get-date).AddDays(-30)}
查询OU中所有账号的创建时间\SID\上次修改密码时间\最后一次登录时间
Get-ADuser -searchbase ‘ DC=rightdo,DC=net ‘ -filter -Properties | Select-Object Name,SID, 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
修改导出的用户信息后再更新
Import-Csv -Path c:\aduserinfo.csv | foreach {Set-ADUser -Identity $.SamAccountName -EmployeeID $.EmployeeID
-Replace @{EmployeeType =$.EmployeeType;description =$.description } }
" \ \ / /_ | / | _ \ / | / / _ | \ | | | / |. " \ \ / / | || |/| | |) | | | | | | | | | | | | | | _.