PowerShell authentication user name and password

Source: Internet
Author: User
Verifying that the user name and password is typically scanned internally periodically to prevent the use of weak passwords.
Of course, the scan should be careful not to exceed the maximum number of errors, so as not to cause locking

The method of password authentication covers two types, one is domain user, one is local user

Authentication Methods for Domain Users:

$Try = New-object System.DirectoryServices.DirectoryEntry ("ldap://dc=contoso,dc=com", "$UserName", "$Password")

When the $try.name is empty, that is, the password is wrong, when the $try.name is not empty, that is, the password authentication is successful, the weak password account


Authentication methods for Local Users:

Add-type-assemblynamesystem. Directoryservices.accountmanagement

$DS = New-objectsystem.directoryservices.accountmanagement.principalcontext ([ System.directoryservices.accountmanagement.contexttype]::machine, "localhost")

$DS. Validatecredentials ("admin", "[email protected]")

The validation here directly returns TRUE or false, that is, whether the validation



PowerShell authentication user name and password

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.