解锁账号: Search-ADAccount -SearchBase 'OU=USERS,OU=RESTRICTED,OU=CHINA,DC=tcsgegdc,DC=com' -LockedOut | Unlock-ADAccount 重置密码: $user = Read-Host -Prompt "请输入员工号" $pwd = ConvertTo-SecureString '密码' -AsPlainText -Force Set-ADAccountPassword -Identity $user -Reset -NewPassword $pwd Unlock-ADAccount -Identity $user 新建用户: $input = Read-Host -Prompt "名 姓 员工号" $detail = $input.Split(" ") $displayname = $detail[0] + ' ' + $detail[1] $upn = $detail[2] + '@tcsgegdc.com' $pwd = ConvertTo-SecureString '密码' -AsPlainText -Force New-ADUser -Server tcsgechidc02 -AccountPassword $pwd -Enabled $true -Name $detail[2] -Path 'OU=USERS,OU=RESTRICTED,OU=CHINA,DC=tcsgegdc,DC=com' -GivenName $detail[0] -Surname $detail[1] -DisplayName $displayname -SamAccountName $detail[2] -UserPrincipalName $upn 删除用户: $user = Read-Host -Prompt "请输入员工号" Remove-ADUser -Server tcsgechidc02 -Identity $user Show-EventLog -ComputerName tcsgechidc02