AD Account Unlocked

Source: Internet
Author: User
Tags argumentlist samaccountname

Get-aduser-filter *-properties *-searchbase "dc=uxin,dc=youxinpai,dc=com" |? {$_.lockedout-eq "true"} |unlock-adaccount

account Unlock Email notification

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#$nlsIf($nls -GT20)    {    foreach($u inch $users) {[array]$uus+=$u. sAMAccountName +"' n"Get-aduser$u. sAMAccountName | unlock-Adaccount}#Defining mail servers    $smtpServer="mail.yy.com"    $smtpUser="[email protected]"    $smtpPassword="Pass"    $mail= new-Object System.Net.Mail.MailMessage#Define sender email address, recipient email address    $MailAddress="[email protected]"    $MailtoAddress="[email protected]"    $mail. from = New-object System.Net.Mail.MailAddress ($MailAddress)    $mail. To.add ($MailtoAddress)    #Define message title, priority, and body    $mail. Subject ="Locked User number is $NLS"; $mail. Priority =" High"    $mail. Body ="Locked AD Users has 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)        }

AD Account Unlocked

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.