This PowerShell one-line generates a reasonably secure password from the characters in the system’s Path. Here I am replacing the space character with the tilde ~ for additional complexity. Get-Enumerator returns each character of the path individually. You can set the password length as the value for the count parameter. $pw = [array](($env:Path).Replace(‘ ‘,’~’).getenumerator() |…
Tag: Scripting
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 Directory. The first will return the GPO displayname attribute from a GUID. The GUID (sometimes…
Add-WindowsFeature Alternative for Client OS
Waiting for the add remove features dialog populate on my client OS computer is slow. Since I started using Add-WindowsFeature wither Server 2008, and Install-WindowsFeature beginning with Server 2012, I was disappointed by the lack of a similar cmdlet for Windows 10. Unfortunately, Add/Install-WindowsFeature relies on ServerManager — which doesn’t exist on a workstation. The…
Fix Creation Date Later than Date Modified with PowerShell
A weird and annoying thing happened to my home directory at work when it was moved from Windows to a storage appliance. The file CreationTime was lost on all the files and was set to the date of the data move. Particularly annoying was seeing the CreationTime being more recent than the LastWriteTime attribute. At…
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…
Get Oldest Windows Event
Get-OldestEvent.ps1 is a PowerShell advanced function which returns the oldest event from a Windows computer event log, and will help you determine the rollover time for an event log by also returning the age of the record as a time span with the time created. Optionally you can return the entire oldest record with the…
Passwords for Password Resets
I discovered that my script to generate passwords, RandomPW.vbs, isn’t popular with users because the passwords are random. I have an even more complicated but unposted PowerShell version with the same issue. I wanted to create something that was easier for the help desk and users. Get-TempPW.ps1 is my answer to those objections. This script…
Test Whether Organizational Unit or Account Exists
Here are two quick functions which I have recently found useful. The first tests whether a user account exists. It takes the Domain and Identity as arguments. Using the “Stop” error action with Try/Catch keeps it from showing any errors. You can do this with any of the AD cmdlets, such as Get-ADOrganizationalUnit, Get-ADComputer and…
That VbScript worked in XP, Why Not Now?
Do you have a script that worked with your x32 XP computer, but no longer works in Windows 7 or 8 x64? I am finding that some of the scripts I wrote have this problem. Somethings may rely on an ActiveX control that was native to XP but not a later version. What I am…
Laptop Return Reminder
We love our users, yes we do! Especially the ones who walk out the door with a laptop that they refuse to return. Having a computer off the corporate network for an extended period of time can create problems with Active Directory, some management software and some encryption software. MakeLaptopWarning.vbs is a script which the…