This script will help you to set the PwdLastSet attribute to the current date and time for multiple users. The user list in this script is built from an organizational unit content. You can adapt it with your own requirement.
Change the user UPN
Disable and move inactive computer accounts
Export users to a CSV file
Export users to a CSV file Script : Script (with Microsoft Active Directory module loaded : import-module activedirectory) : Get-ADUser -filter * -ResultSetSize $null -Properties SamAccountName,displayname,description ` | select-Object SamAccountName,displayname,description ` | Export-Csv “c:\folder\export.csv” Script (with Quest Active Directory module)
Retrieve the domain controller hostnames in a forest
With this script, you will be able to retrieve the domain controller hostnames in a forest. $myForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() $myforest.Sites | % { $_.Servers } | Select Name, Domain References MSDN Forest Class Properties Name Description ApplicationPartitions Gets a collection
Find all locked out user account
Find all locked out user account This cmdlet lists all locked out user account in the current Active Directory domain Script : Search-ADAccount -LockedOut | select DistinguishedName References Search-ADAccount Syntax Search-ADAccount -AccountDisabled [-AuthType { | }] [-ComputersOnly ] [-Credential ]
Enumerate all domains in a forest
You will be able to enumerate all domains in a forest : the script lists all domain names (FQDN) in an Active Directory forest Script : @(([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).Domains |select name ) References System.DirectoryServices.ActiveDirectory Namespace The System.DirectoryServices.ActiveDirectory namespace provides a high level abstraction object
Find an email address in the forest
With this script you will be able to find an email address in the forest and identify the Active Directory object linked on. (Get-ADobject -Filter {(mail -eq “johndoe@mail.com”)} -Properties sn,givenname,mail,displayname -SearchBase “dc=domain,dc=root” -Server “dc01.domain.root:3268” | ` Select-Object displayname,sn,givenname,mail) References Get-ADObject
Cleanup data when the user account no longer exists
Copy the group members to another group
This script copy the group members to another group. You have the choice between Microsoft Active Directory cmdlet or the Quest Active Directory cmdlet. Script (with Microsoft Active Directory module loaded : import-module activedirectory) : $Source_Group = “CN=SourceGroupName,OU=Groups,DC=domain,DC=com” $Destination_Group =