Alan's Blog

"Yeah. I wrote a script that will do that."

Menu
  • About My Blog
Menu

Tag: Active Directory

Tips for Implementing Group Managed Service Accounts in an AD Forest

Posted on July 27, 2019July 27, 2019 by Alan

TLDR: Group Managed Service Accounts (gMSAs) are limited to the domain in which they are created. gMSAs are not reported by Get-ADUser. Managed Service Accounts (MSAs) were introduced in Server 2008 R2 to allow for system managed password changes of service accounts. Group Managed Service Accounts were introduced in Server 2012 as an improvement to…

Read more

Get AD Schema Attribute Names

Posted on December 2, 2018 by Alan

One of our admins was running my export and import permissions script, and I thought he had made an error when I looked at an ExtensionAttribute name.  Nope.  The difference was between the attribute name and the LDAP display name which you see in the Attribute Editor tab from the advanced view of Active Directory…

Read more

Get User Lockout Status with PowerShell

Posted on September 15, 2018September 15, 2018 by Alan

Get-UserLockoutStatus.ps1 is an interactive script to get the lockout status of a selected user or all users in a specified domain.  It queries each domain controller for non-replicated attributes using a workflow with an inline script for speed.  It requires the ActiveDirectory Module.

Read more

Create a Hash Table with AD Domain DNS Root and NetBIOS Names

Posted on September 2, 2018 by Alan

I frequently get requests to modify or lookup a list of user names in a CSV file where the username is NTDomain\SamAccountName.   Get-ADUser will let you use the NT domain as a server name, but in my experience it is slower than using the domain’s FQDN.  Before I import the list in my code, I…

Read more

Reset User Account ACLs

Posted on October 22, 2017 by Alan

The security for user account objects in an OU may drift over time. User accounts moved within the domain will retain delegations previously made, and user accounts created after schema extensions won’t have the same security as user accounts created earlier in time. Reset-UserAccountACLs.ps1 resets the security (ACLs) for user accounts within an OU to…

Read more

Using Workflows to Multithread AD Queries

Posted on October 22, 2017 by Alan

I am frequently called on for Active Directory reports for all domains in the forest.  This code shows you how to use a workflow to easily do this, adding the domain data into the results: WorkFlow Run-wfADQuery { param([string[]]$Domains,[string]$filter) ForEach -parallel ($Domain in $Domains){ InLineScript { $userList =get-aduser -filter $using:filter -server $using:Domain @(Foreach ($user in…

Read more

Getting GPO GUID, Name from Active Directory

Posted on October 20, 2017 by Alan

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 Directory. The first will return the GPO displayname attribute from a GUID. The GUID (sometimes…

Read more

Undelete-ADObject

Posted on September 17, 2017 by Alan

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.  It has a test mode, plus logging.

Read more

Powershell Date LDAP filters

Posted on August 13, 2017 by Alan

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()[5].ToString().Replace(“-“,”)+’000000.0Z’ $LDAPFilter = “(WhenCreated>=$ldapStart)” Get-aduser -LDAPFilter $ldapfilter -properties whencreated  

Read more

OU of Current PC from anywhere in the Forest

Posted on August 12, 2017September 23, 2017 by Alan

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…

Read more
  • Previous
  • 1
  • 2
  • 3
  • 4
  • Next

Search

Please Note

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 later.

https connections are supported.

All new users accounts must be approved, as are comments. Please be patient.  If you find a post error or a script which doesn’t work as expected, I appreciate being notified.  My email is my first name at the domain name, and you are welcome to contact me that way.

Tags

1E ACLS Active Directory ActiveDirectory ADSI Advanced Functions Audit Change Administrator Password COMObject Computer Groups DateTime Desktop DNS Excel FileScriptingObject Forms General GPO GPS Group Policy Hacks ISE Lockout logons NAV740 Nessus OU OU permissions Outlook Pick Folder Power PowerShell Powershell Scriptlets RDP SCCM schedule reboot Scripting Security Shell.Application user information VBA Windows Update WMI WordPress WPF

Categories

akaplan.com

  • Back to Home Page

Archives

Scripting Sites

  • A Big Pile of Small Things
  • Adam, the Automator
  • Art of the DBA
  • Ashley McGlone
  • Boe Prox
  • Carlo Mancini
  • DexterPOSH
  • Doug Finke
  • Jaap Brasser's Blog
  • JeffOps The Scripting Dutchman
  • Jonathan Medd's Blog
  • Keith Hill's Blog
  • LazyWinAdmin
  • Nana Lakshmanan
  • PowerShell Magazine
  • PowerShell Team Blog
  • PowerShell.org
  • PwrShell.net
  • Richard Siddaway's Blog
  • Ryan Yates' Blog
  • Skatterbrainz
  • The Lonely Administrator

SQL Site

  • Art of the DBA

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2025 Alan's Blog | Theme by SuperbThemes

Terms and Conditions - Privacy Policy