• 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)
        
        }
  • 相关阅读:
    Linux下查看文件和文件夹大小的df和du命令(链接)
    路由的原理和作用[赛迪网]
    select 好用插件
    如何启动/停止/重启MySQL
    Spirng quartz 整合
    String,StringBuffer与StringBuilder的区别
    如何给input[file]定义cursor
    dns简介
    浏览器高级对象
    shell 学习文章列表
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/5577464.html
Copyright © 2020-2023  润新知