Category Archives: Active Directory

Getting GPO GUID, Name from 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

Posted in Active Directory, Functions, Group Policy Objects, PowerShell, Scripting, Scriptlets | Tagged , , , | Leave a comment

Undelete-ADObject

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

Posted in Active Directory, Alan's Favorites, PowerShell, Scripting, Windows Administration | Tagged , | Leave a comment

Export and Import Delegated OU Permissions with PowerShell

There are some delegations of permissions within Active Directory which cannot be made without extra effort. Some properties are flagged as hidden in a file called Dssec.dat, in %windir%\System32 on computers with the Active Directory Users and Computers (ADUC) MMC. … Continue reading

Posted in Active Directory, Alan's Favorites, My Best, PowerShell, Scripting, Security, Windows Administration | Tagged , , , | Leave a comment

Clear GPO Cache on Remote Computer with PowerShell

Clearing the GPO cache on a computer may be the only way to fix a persistent problem.  Doing this involves deleting files, registry entries, and rebuilding the security database.  Clear-GPOCache.ps1 works by creating a custom batch file on the remote … Continue reading

Posted in Active Directory, Batch, Group Policy Objects, PowerShell, Scripting, Windows Administration | Tagged , | Leave a comment

Powershell Date LDAP filters

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:

 

Posted in Active Directory, PowerShell, Scripting, Scriptlets | Tagged , | Leave a comment

OU of Current PC from anywhere in the Forest

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:

Update: 9/23/2017: You can also get this … Continue reading

Posted in Active Directory, Scripting, Scriptlets | Tagged , | Leave a comment

Create an AD Drive for Specified Domain

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

Posted in Active Directory, Functions, PowerShell, Scripting | Tagged , , | Leave a comment

Get All GPOs Linked to an OU

Get-AllGPOsLinkedToOU.ps1 returns a unique list of all GPO’s linked to an OU. You can also run a onelevel or subtree search to get a unique list of linked OUs at or below the selected OU. You are prompted for the … Continue reading

Posted in Active Directory, Group Policy Objects, PowerShell, Windows Administration | Tagged , | Leave a comment

Reset GPO Cache

This script deletes the locally stored copies of GPOs and forces a GPUPdate on a computer. Reset-GPOCache.ps1 works by a remote connection to the registry provider to get the path to the Group Policy\History folder, then deletes the files beneath … Continue reading

Posted in Active Directory, Group Policy Objects, PowerShell, Windows Administration | Tagged , | Leave a comment

Get Resultant Set of Polices (RSOP) with User Selection

The Get-GPResultantSetOfPolicy cmdlet in the GroupPolicy module of PowerShell has a parameter for a user name.  Often I have no idea who has logged onto the computer.  Get-RSOP.ps1 uses WMI to give you a pick list of users on the … Continue reading

Posted in Active Directory, Group Policy Objects, PowerShell, Scripting, Windows Administration | Tagged , | Leave a comment