Category Archives: Scriptlets

Practical Lessons on WPF Forms and PowerShell

Last weekend I decided that I was finally going to figure out how to stop using Windows Forms, and move to the newer Windows Presentation Foundation (WPF).  Some time ago, I had read a WPF blog post from FoxDeploy.com, which … Continue reading

Posted in Functions, PowerShell, Scripting, Scriptlets | Tagged , , | Leave a comment

Where am I? Getting the Name of the Currently Executing Function

I almost always debug scripts by stepping through them.  But sometimes it is nice to just have a way to write the current function during execution.   I use this:

This uses the .NET formatting style, where the contents … Continue reading

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

Two Ways to Get Mapped Drives with WMI

For years I have been getting mapped drives from WMI using Win32_NetworkConnection. Typical code looks like this in PowerShell:

I have been using a product called ExpanDrive to map my cloud storage to drive letters.  When I tried to … Continue reading

Posted in PowerShell, Scripting, Scriptlets, WMI | Tagged , | Leave a comment

Using Workflows to Multithread AD Queries

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:

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

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

PowerShell Get Column Names for a CSV File

Get-Member doesn’t always show you what is under the hood for an object.  For that you need the .PSObject property.  Here PSObject.Properties contains CSV column names

Posted in PowerShell, Scriptlets | 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

PowerShell Pause with Progress Bar

This snippet of PowerShell was written to have show users something more interesting than “Sleeping for 15 seconds” in a script.  Notice that I splat the progress parameters.

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

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 … Continue reading

Posted in PowerShell, Scripting, Scriptlets, Windows Administration | 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