zoukankan      html  css  js  c++  java
  • AD账号解锁

    Get-ADUser -Filter * -Properties *  -SearchBase "dc=uxin,dc=youxinpai,dc=com"| ? {$_.lockedout -eq "true"} |unlock-adaccount

    账号解锁发邮件通知

    Import-Module activedirectory
    
    $users = Get-ADUser -Filter * -Properties *  -SearchBase "dc=uxin,dc=youxinpai,dc=com"| ? {$_.lockedout -eq "true"}
    #$unames = $users|select samaccountname
    $nls = ($users|measure).count
    #$nls
    If ($nls -gt 20)
        {
        foreach ($u in $users)
        {
        [array]$uus +=$u.samaccountname + "`n"
        
        Get-ADUser $u.samaccountname |Unlock-ADAccount
        }
    
        #定义邮件服务器
        $smtpServer = "mail.yy.com"
        $smtpUser = "sysuser@yy.com"
        $smtpPassword = "pass"
        $mail = New-Object System.Net.Mail.MailMessage
    
        #定义发件人邮箱地址、收件人邮箱地址
        $MailAddress="sysuser@yy.com"
        $MailtoAddress="ITsupport@yy.com"
        $mail.From = New-Object System.Net.Mail.MailAddress($MailAddress)
        $mail.To.Add($MailtoAddress)
    
        #定义邮件标题、优先级和正文
        $mail.Subject = "Locked User Number is $nls";
        $mail.Priority  = "High"
        $mail.Body = "Locked AD Users have UNlocked.Users is:`n $uus"
        $smtp = New-Object System.Net.Mail.SmtpClient -argumentList $smtpServer
        $smtp.Credentials = New-Object System.Net.NetworkCredential -argumentList $smtpUser,$smtpPassword
        $smtp.Send($mail)
        
        }
  • 相关阅读:
    快速创建ssm项目
    String 的基础知识点梳理一
    消息中间件ActiveMQ
    log4j.properties
    数据库基础
    pycharm快捷键
    HTML其他标签
    HTML基本标签
    概率论基础2
    概率论基础1
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/5577464.html
Copyright © 2011-2022 走看看