域账号相关的脚本

解锁账号:
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

 

posted @ 2015-05-08 14:50  dongdonggeorge  阅读(455)  评论(0编辑  收藏  举报