天天看点

ADMT迁移账户后的关联操作

  • 修改UPN

Import-Module activedirectory

$users = Get-ADUser -SearchBase "ou=ttemp,ou=tt,ou=staff,dc=hello,dc=com" -Filter *

foreach($i in $users){
  $id = $i.SamAccountName 
  #$upn = $i.UserPrincipalName
  #Write-Output $id,$upn
 
  Set-ADUser -Identity $id -UserPrincipalName "[email protected]"

}
           
$users = Get-ADUser -SearchBase "ou=ttempou=tt,ou=staff,dc=hello,dc=com" -Filter * -Properties *| ? {$_.whencreated -gt '2022/04/05'}

foreach($i in $users){
  $id = $i.SamAccountName 
  #$upn = $i.UserPrincipalName
  #Write-Output $id,$upn
 
  Set-ADUser -Identity $id -UserPrincipalName "[email protected]"

}

           
  • 取消首次登陆修改密码选项

Get-ADUser -Filter {pwdLastSet -eq 0} -SearchBase  "ou=ttemp,ou=tt,ou=staff,dc=hello,dc=com" | Set-ADUser -ChangePasswordAtLogon $false

           
  • 某些功能性账号密码永不过期(在特定OU下)

Get-ADUser -Filter * -SearchBase  "ou=Service_Accounts,ou=tt,ou=staff,dc=hello,dc=com"  | Set-ADUser -PasswordNeverExpires $true

           

继续阅读