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 this remote drive became important to me. Here is an example of the…
Tag: PowerShell
Update to Dot Source Reminder with Search and Replace
“The pause doesn’t work for me”, said one of my team members about the pause function in my Dot Source Reminder code. We took some time to analyze why and found that his shell settings were different from mine. Instead I decided to focus on whether the code executed inside the ISE. Next was to…
Get MAC Address from IP Address
I got a call last week from a member of one the other teams where I work. He asked, “Do you have a script which will resolve a list of IP Addresses to MAC Addresses?” My answer was, “not yet”. I did a search and found some very convoluted Pinvoke code. I wanted something easier….
Open the PowerShell ISE (and other Programs) with Alternate Credentials
RunAS for PowerShell is pretty easy. This opens the ISE: sl “c:\” $cred = Get-Credential $Prog = “c:\windows\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe” Start-Process $Prog -Credential $cred
Update GPOs with Newer Version
If you use GPOs to enforce baselines, you may find that your enterprise is moving from version 1.1 to version 1.2 of a GPO. Unfortunately for you, version 1.1 linked in a dozen places. Wouldn’t you rather just you search for version 1.1 and replace it with version 1.2? Use Update-GPOLinks.ps1 to do just that. …
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 domain, and navigate to desired OU.
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 that path. This ensures a fresh application of group polices.
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 remote computer and then passes that to the user parameter of Get-GPResultantSetOfPolicy.
Remove Active Directory Delegations
Over time, Active Directory delegations tend to accumulate and drift from the standards in the enterprise. Removing the delegations for a user or group can be slow, especially if you do it manually. Microsoft has a good article about this process, but none of the methods I found did what I needed. I wanted a script which…
A Dot Source Reminder for Advanced Functions
One of the problems with writing advanced functions is that new PowerShell users think that they don’t do anything. Frankly, I couldn’t figure out a way to get a notification to work, so I reached out to the sponsor for the Charlotte PowerShell User Group, Microsoft PFE Brian Wilhite. Brian sent me some code which…