All the scripts are saved as .txt files. Newer files have a "View Script" button which will let you save or open a script in notepad. For earlier posts, the easiest way to download with IE is to right click on the link and use "Save Target As". Rename file from Name_ext.txt to Name.ext.
To see a full post after searching, please click on the title.
PowerShell Scripts were written with Version 3 or 4.
https connections are supported.
All new users accounts must be approved, as are comments. Please be patient. It is pretty easy to figure out my email address from the scripts, and you are welcome to contact me that way.
Top Posts & Pages
- Delete Inactive User Profiles with PowerShell
- Getting GPO GUID, Name from Active Directory
- Delete a List of Computer Accounts from Active Directory
- Scriptomatic on Windows 7 Solved
- Export DNS Server Records with PowerShell
- Convert data from Get-ADUser and Get-ADComputer for Export-CSV
- Programatically Uninstall Outlook Patch KB2412171
- Who Joined Computer Account to AD Domain
- Export PowerShell script output to Text with Out-Notepad
- LDAP Ping
Tag Archives: Active Directory
You don’t have to rely on the Group Policy Module to resolve the display name of a GPO from the GUID, or the GUID from the display name. Here are two short functions that will get that information from Active … Continue reading
Undelete-ADObject.ps1 is a GUI form based script for undeleting user, computer, group, print queue, and contacts from Active Directory. You can display all of the objects of the selected type, or search by the name. I use this script frequently. … Continue reading
This snippet can be used for easier date formatting when using an LDAP date filter with PowerShell. This demonstrates how to get users created within the previous 30 days using LDAP:
$MaxDays = 30
$StartDate = (Get-date).AddDays(-$MaxDays)
#Set to begin at midnight
$ldapStart = $StartDate.GetDateTimeFormats().ToString().Replace("-",'')+'000000.0Z'
$LDAPFilter = "(WhenCreated>=$ldapStart)"
Get-aduser -LDAPFilter $ldapfilter -properties whencreated
There are a lot of ways to get the OU of the current computer, but most don’t work if you are outside your home domain. This code does, without requiring AD cmdlets:
#My Computername works anywhere in forest
$strFilter = "(&(objectCategory=Computer)(Name=$env:computername))"
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.Filter = $strFilter
$searchRootName = [system.directoryservices.activedirectory.forest]::GetCurrentForest().Name.ToString()
$SearchRoot = "GC://"+$SearchRootName
$objSearcher.SearchRoot = $SearchRoot
$objPath = $objSearcher.FindOne()
$dn = ($objPath.GetDirectoryEntry()).Path
$MyPCOU = $dn.Substring($dn.IndexOf("OU"),$dn.Length-$dn.IndexOf("OU"))
Update: 9/23/2017: You can also get this … Continue reading
When you load the Active Directory Module, you get, by default, an Active Directory PSDrive for the current domain. You can avoid the drive from loading by setting $Env:ADPS_LoadDefaultDrive = 0. When writing scripts to export and import AD delegations, connecting to … Continue reading
Add-ADTSInfo.ps1 adds TerminalServicesHomeDrive, TerminalServicesHomeDirectory, TerminalServicesProfilePath and AllowLogon as additional members returned by a query of Active Directory user objects. As you may know, when looking at a user’s properties in the Active Directory Users and Computers MMC there is a tab … Continue reading
Repadmin is a standard tool in an AD admin’s toolbox, and “showrepl” displays the status of replication in your domain. The results of this command are quite verbose, and can make your eyes glaze over in late night troubleshooting. A … Continue reading
How can you tell whether an Active Directory domain controller is functioning properly? How do you know whether some over-zealous VLAN ACL is blocking necessary ports? Testing ICMP, is easy, just ping it. Testing LDAP response isn’t hard, I wrote … Continue reading
OUADSPathToClip.ps1 is an updated version of OUADSPath2Clip.ps1 and is an example implementation of the new Select-OU.ps1 script. Fast navigation of OU structure to copy the OU’s DistinguishedName into your clipboard. Version 1.1 allows control of form and button text.