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…
Get Downtime Using PowerShell
I have been having problem with a computer with random reboots, and hanging on restart. I wanted to know how long the computer had been unavailable. I decided to use System Event ID 12 as the startup event for the purposes of my calculations. The script takes these steps: 1) connect to the remote system…
Export to HTML with Style Sheet Header
$txtColor = ‘AliceBlue’ $file = “$env:temp\TempHTML.htm” $HTMLHeader =@” <style> BODY{background-color:white;} TABLE{border-width: 1px;border-style: solid;border-color: black; border-collapse: collapse;margin-left:auto; margin-right:auto;} TH{border-width: 1px;padding: 1px;border-style: solid; border-color: black;background-color:$txtColor} TD{border-width: 1px;padding: 1px;border-style: solid; border-color: black;background-color:$txtColor} </style> “@ #Example $title= ‘Service Information’ Get-Service | Select-Object Status, Name, DisplayName,Starttype | ConvertTo-HTML -head $HTMLHeader -body “<center><H2>$title</H2><Font=Verdana></Center>” | Out-File $file Invoke-Expression $file This a…
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…
Fix User’s Home Directory Permissions with Take Ownership
Fix-HomeDrivePerms.ps1 is a PowerShell script which attempts to reset folder security when the permissions are really hosed. It uses a take ownership function, Set-Owner, by Boe Prox, instead of takeown.exe, but does shell out to iCacls.exe. I wrote this to fix home directories where a user might be logged on with files open a the…
Another User Folder Security Reset Script
This simple batch file resets the inheritance on users folders and then grants them “modify” using the builtin icacls.exe. This script does not address issues which require you to take ownership — I will post one that does that soon. @Echo Off Pushd \\path\USERS\ for /d %%u in (*.*) do echo ICACLS %%~fu /reset /t…
Set Share Folder Icon for Server 2012 and Windows 10
I like to look at a folder and know whether or not it is shared. In earlier Windows OS there was a hand overlay which shows you this information. In Server 2012, this indicator has been omitted. Set-SharedFolderIcons.ps1 lets you use the icon of your choosing to restore this hint that a folder is shared. …
Adding Terminal Services Information to User Reports
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 for these fields. However, if you look at the properties of a user object, these…