active directory cheatsheet

Active Directory Cheat Sheet

This page contains my Active Directory Cheat Sheet. A list of collected one liners and vb scripts. Enjoy and feel free to add some yourself via comments!

Active Directory One Liners

This isn’t so much a script as an awesome way to reset an active directory user’s password.

How to Reset Active Directory User’s Password from Command Line

In this case you would need to be on the domain controller to run this:

Remotely Reset Active Directory User’s password from command line

Requirements

  • You must have admin rights to domain controller
  • psexec

Return the distinguished name for all users in an active directory domain

To return the distinguished name for all users in an active directory domain create a new file called getdn.bat

Content:

List all users in security group

Export all usernames and email addresses

sync time domain controller

FSMO Roles

Global Catalog

Domain Controllers

Domain Controller IP Configuration

Stale computer accounts

Stale user accounts

Disabled user accounts

AD Database disk usage

Global Catalog Servers from DNS

Global Catalog Servers from AD

Users with no logon script

User accounts with no pwd required

User accounts with no pwd expiry

User accounts that are disabled

DNS Information

DNS Zone Detailed information

Garbage Collection and tombstone

Netsh authorised DHCP Servers

DSQuery authorised DHCP Servers

DHCP server information

DHCP server dump

WINS serer information

Group Policy Verification Tool

AD OU membership

AD OU membership

List Service Principal Names

Compare DC Replica Object Count

Check AD ACLs

NTFRS Replica Sets

NTFRS DS View

Domain Controllers per site

DNS Zones in AD

Enumerate DNS Server Zones

Subnet information

List Organisational Units

ACL on all OUs

Domain Trusts

Print DNS Zones

Active DHCP leases

DHCP Server Active Scope Info

Resolve DHCP clients hostnames

Find two online PCs per subnet

AD Subnet and Site Information

AD Site Information

Printer Queue Objects in AD

Group Membership with user details

Total DHCP Scopes

Site Links and Cost

Time gpresult

Check time against Domain

Domain Controller Diagnostics

Domain Replication Bridgeheads

Replication Failures from KCC

Inter-site Topology servers per site

Replication latency

Queued replication requests

Show connections for a DC

Replication summary

Show replication partners

All DCs in the forest

ISTG from AD attributes

Return the object if KCC Intra/Inter site is disabled for each site

Find all connection objects

Find all connection schedules

Software Information for each server

Check Terminal Services Delete Temp on Exit flag

For each XP workstation, query the current site and what Group Policy info

Information on existing GPOs

Copy all Group Policy .pol files

Domain Controller Netlogon entries

WINS Statistics

WINS Record counts per server

WINS Server Information

WINS Server Dump

WINS Static Records per Server

Find policy display name given the GUID

Find empty groups

Find remote NIC bandwidth

Find remote free physical memory

Find remote system information

Disk statistics, including the number of files on the filesystem

Query IIS web sites

Check port state and connectivity

Forest/Domain Functional Levels

Forest/Domain Functional Levels

Find the parent of a process

Lookup SRV records from DNS

Find when the AD was installed

Enumerate the trusts from the specified domain

Find a DC for each trusted domain

Check the notification packages installed on all DCs

List ACLs in SDDL format

Find out if a user account is currently enabled or disabled

Find servers in the domain

Open DS query window

VBScripts to manage Active Directory Users

Export All users from OU
Appending a Multi-Valued Attribute
Appending a Phone Number
Adding a Route to the Dial-In Properties of a User Account
Adding a User to Two Security Groups
Appending Address Page Information for a User Account
Appending a Home Phone Number to a User Account
Assigning a Published Certificate to a User Account
Changing User Account Attributes
Changing a User Password
Clearing Address Page Information for a User Account
Clearing All Published Certificates from a User Account
Clearing Department and Direct Report Information from a User Account
Clearing Telephone Attributes
Clearing Telephone Properties for a User Account
Clearing User Account Address Attributes
Clearing User Account Attributes
Configuring Account Page Information for a User Account
Configuring Address Page Information for a User Account
Configuring COM+ Information for a User Account
Configuring Dial-In Properties for a User Account
Configuring the Expiration Date for a User Account
Configuring Organization Properties for a User Account
Copying a Published Certificate to a User Account
Configuring the UPN Suffixes Defined in the Forest
Configuring User Account Telephone Numbers
Configuring User Profile Properties
Configuring User Profile Properties for a User Account
Configuring User Telephone Properties
Copying Allowed Logon Hours from One Account to Another
Creating 1,000 User Accounts
Creating an Active Directory User Account
Creating a Contact in Active Directory
Creating a User, a Group, and an OU
Deleting a Calling Station ID from a User Account
Deleting One Telephone Number from a User Account
Deleting a Phone Number
Deleting a Post Office Box from a User Account
Deleting Published Certificates from a User Account
Deleting Single- and Multi-Valued Attributes
Deleting a User Account from Active Directory
Determining When an Account Expires
Determining the Owner of a User Account
Determining When a Password Expires
Determining When a Password was Last Set
Determining User Account Status
Determining When a User Account Expires
Determining User Logon Hours
Disabling a Password Flag
Disabling the Smartcard Required Attribute for a User Account
Disabling a User Account
Disabling the User Cannot Change Password Option
Displaying Allowed Logon Hours for a User Account
Displaying Domain Password Attributes
Displaying Password Property Attributes
Displaying User Account Password Attributes
Enabling a User Account
Ensuring that an Account will not Expire
Modifying User Profile Paths
Moving a User Account
Moving a User Account to a New Domain
Preventing a User From Changing His or Her Password
Requiring a Password Change
Requiring a User to Logon on Using a Smartcard
Retrieving Organization Information
Retrieving User Account Account Properties
Retrieving User Profile Properties
Setting an Account Expiration Date
Setting a Password So It Never Expires
Setting the Primary Group for a User
Setting a Users Password
Unlocking an Active Directory User Account
Writing User Account Properties


 

Export all users from OU

Appending a Multi-Valued Attribute

Adds an additional URL to a user account. Demonstrates how to append a new value to a multi-valued attribute.

Appending a Phone Number

Appends an additional home phone number for a user.

Adding a Route to the Dial-In Properties of a User Account

Appends a new route to the Dial-In properties of a user account in Active Directory. This operation adds the new route without deleting any existing routes.

Adding a User to Two Security Groups

Adds a user (MyerKen) to two different Active Directory security groups: Atl-Users and NA-Employees.

Appending Address Page Information for a User Account

Appends new entries to the postOfficeBox attribute of an Active Directory user account. This operation adds the new post office boxes without deleting any existing entries.

Appending a Home Phone Number to a User Account

Appends a new phone number to the otherHomePhone attribute of an Active Directory user account. This operation adds the phone number to the attribute without deleting ant existing phone numbers.

Assigning a Published Certificate to a User Account

Copies a published certificate from a template account (userTemplate) and assigns it to the MyerKen Active Directory user account. This operation replaces any existing published certificates for the MyerKen account.

Changing User Account Attributes

Configures user account attributes found on the General Properties page of the user account object in Active Directory users and Computers.

Changing a User Password

Changes the password for a user. Requires you to know the user’s previous password.

Clearing Address Page Information for a User Account

Removes all information for the c (country) and postOfficeBox attributes of the MyerKen Active Directory user account.

Clearing All Published Certificates from a User Account

Removes all published certificates for the MyerKen Active Directory user account.

Clearing Department and Direct Report Information from a User Account

Removes all information from the deparment, directReports, and manager attributes of the MyerKen Active Directory user account.

Clearing Telephone Attributes

Clears selected telephone-related attributes for a user account.

Clearing Telephone Properties for a User Account

Removes all information from the info and otherPager attributes of the MyerKen Active Directory user account.

Clearing User Account Address Attributes

Clears selected address-related attributes for a user account.

Clearing User Account Attributes

Clears selected attributes for a user account.

Configuring Account Page Information for a User Account

Configures basic account information for the MyerKen Active Directory user account.

Configuring Address Page Information for a User Account

Configures address-related information for the MyerKen Active Directory user account.

Configuring COM+ Information for a User Account

Sets COM+ information for the MyerKen Active Directory user account.

Configuring Dial-In Properties for a User Account

Configures Dial-In attribute values for the MyerKen Active Directory user account.

Configuring the Expiration Date for a User Account

Configures the MyerKen Active Directory user account to expire on March 30, 2003.

Configuring Organization Properties for a User Account

Configures organization information for the MyerKen Active Directory user account. The script also assigns MyerKen as the manager for LewJudy and AkersKim.

Copying a Published Certificate to a User Account

Copies a published certificate from a template account (userTemplate) to the MyerKen Active Directory user account. This operation appends the new certificate without deleting any existing certificates.

Configuring the UPN Suffixes Defined in the Forest

Configures the upnSuffixes attribute of the Partitions container and displays the new values to the operator.

Configuring User Account Telephone Numbers

Configures telephone numbers and calling information for the MyerKen Active Directory user account.

Configuring User Profile Properties

Configures user profile settings for a user account.

Configuring User Profile Properties for a User Account

Configures user profile properties for the MyerKen Active Directory user account.

Configuring User Telephone Properties

Configures telephone numbers and telephone-related attributes for a user account.

Copying Allowed Logon Hours from One Account to Another

Copies the allowed logon hours from a template account (userTemplate) and assigns them to the MyerKen Active Directory user account. The MyerKen account will thus have the same logon hour restrictions as those assigned to the userTemplate account.

Creating 1,000 User Accounts

Demonstration script that creates 1,000 user accounts (named UserNo1, UserNo2, UserNo3, etc.) in the Users container in Active Directory. The script is useful for test scenarios that require multiple user accounts.

Creating an Active Directory User Account

Creates a user account in Active Directory. This script only creates the account, it does not enable it.

Creating a Contact in Active Directory

Creates a contact account named MyerKen in the Management organizational unit in a hypothetical domain named fabrikam.com.

Creating a User, a Group, and an OU

Demonstration script that: 1) creates a new Active Directory organizational unit; 2) creates a new user account and new security group; and, 3) adds the new user as a member of that security group.

Deleting a Calling Station ID from a User Account

Removes a specific calling station ID from the MyerKen Active Directory user account. This operation only removes the specified calling station ID; no other IDs are deleted.

Deleting One Telephone Number from a User Account

Deletes a phone number from the otherMobile attribute of the MyerKen Active Directory user account. This operation removes only one phone number (425-555-0113) without affecting any other phone numbers.

Deleting a Phone Number

Deletes a phone number from a user account with multiple mobile phone numbers.

Deleting a Post Office Box from a User Account

Removes a specified value (2224) from the postOfficeBox attribute of the MyerKen Active Directory user account. This operation removes only the specified post office box; other entries will not be deleted.

Deleting Published Certificates from a User Account

Retrieves a set of published certificates from a template account (userTemplate), and then deletes each of those certificates from the MyerKen Active Directory user account.

Deleting Single- and Multi-Valued Attributes

Deletes selected attributes from a user account. Demonstrates how to delete single-valued attributes as well as how to delete a single entry from a multi-valued attribute.

Deleting a User Account from Active Directory

Deletes the user account for MyerKen from the HR organizational unit in a hypothetical domain named fabrikam.com.

Determining When an Account Expires

Returns the expiration date for a user account.

Determining the Owner of a User Account

Reports the owner of the MyerKen Active Directory user account.

Determining When a Password Expires

Determines the date when a user password will expire.

Determining When a Password was Last Set

Identifies the last time a user password was set.

Determining User Account Status

Identifies whether a user account is enabled or disabled.

Determining When a User Account Expires

Reports the date that the MyerKen Active Directory user account expires.

Determining User Logon Hours

Retrieves the allowed logon hours for a user.

Disabling a Password Flag

Disables the option allowing a password to be stored using reversible encrypted text.

Disabling the Smartcard Required Attribute for a User Account

Disables the setting that required MyerKen to use a smartcard when logging on to Active Directory.

Disabling a User Account

Disables a user account.

Disabling the User Cannot Change Password Option

Disables the User Cannot Change Password option, allowing the user to change their password.

Displaying Allowed Logon Hours for a User Account

Returns the allowed logon hours for the MyerKen Active Directory user account.

Displaying Domain Password Attributes

Displays password policy settings for the domain.

Displaying Password Property Attributes

Displays password settings for the domain.

Displaying User Account Password Attributes

Displays password-related attributes for an individual user account.

Enabling a User Account

Enables a user account.

Ensuring that an Account will not Expire

Configures a user account so that it will not expire. This is done by setting the expiration date to 1/1/1970.

Modifying User Profile Paths

Changes the server name portion of the user profile path to \\fabrikam for the MyerKen Active Directory user account.

Moving a User Account

Moves a user account from one OU to another.

Moving a User Account to a New Domain

Uses the MoveHere method of IADsContainer to move a user account to another domain. Note that there are a number of restrictions associated with performing this type of move operation. For details, see the Directory Services Platform SDK.

Preventing a User From Changing His or Her Password

Enables the User Cannot Change Password option, which prevents the user from changing their password.

Requiring a Password Change

Forces a user to change their password the next time they logon.

Requiring a User to Logon on Using a Smartcard

Configures the MyerKen user account so that the user must use a smartcard in order to logon to Active Directory.

Retrieving Organization Information

Retrieves user account attributes found on the Organization page of the user account object in Active Directory Users and Computers.

Retrieving User Account Account Properties

Retrieves user account attributes found on the Account page of the user account object in Active Directory Users and Computers.

Retrieving User Profile Properties

Retrieves user account attributes found on the Profile page of the user account object in Active Directory users and Computers.

Setting an Account Expiration Date

Configures a user account to expire on 3/30/2003.

Setting a Password So It Never Expires

Configures the domain password for a user account to ensure that the password will never expire.

Setting the Primary Group for a User

Sets the primary group for the MyerKen Active Directory user account to MgmtUniversal.

Setting a Users Password

Configures a new password for a user.

Unlocking an Active Directory User Account

Unlocks the MyerKen Active Directory user account.

Writing User Account Properties

Configures general attributes for a user account.