Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Testing domain AD credential with PowerShell one liner

This is a one liner command script to connect to Active Directory and verify user name and password credentials provided. I am using  System.DirectoryServices.DirectoryEntry .net object here to connect to LDAP server (In my case it is Active Directory). When you are connected successful with correct information you get DistinguishedName and Path information of Active directory in return.

PowerShell test ad active directory credentials username and password without login ldap domain controller one liner.png

New-Object System.DirectoryServices.DirectoryEntry('LDAP://DC=vcloud-lab,DC=com', 'domain\username', 'password')

If provided Ad credentials are not valid you will see error 'The username or password is incorrect.'

PowerShell test ad active directory credentials username and password without login ldap domain controller one liner bad username and password.png

Below are the object properties information you can provide in the New-Object arguments.

string path
string path, string username, string password)
string path, string username, string password, System.DirectoryServices.AuthenticationTypes authenticationType)
System.Object adsObject

Useful Articles
Powershell one liner: Create multiple user accounts
Active Directory Powershell: Create bulk users from CSV file
Active Directory Powershell: Aduser A value for the attribute was not in the acceptable range of values
Powershell Active Directory: ADGroup Managedby - Checkbox Manager can update membership list


Powershell Active Directory: Show treeview of User or Group memberof hierarchyPowershell Active Directory: List complete hierarchy of upstream nested groups recursively of User
Powershell Active Directory: Show treeview of User or Group memberof hierarchy
Powershell Active Directory: Show treeview of nested Group members downstream hierarchy
Oneliner Microsoft Powershell Script Get members from a list of group from Active Directory in excel
Powershell Active Directory 1: Check, enable and disable child OU protect object from accidental deletion
Oneliner Powershell how to add or remove AD user members and objects in groups

Go Back

Comment

Blog Search

Page Views

11401577

Follow me on Blogarama