Skip to content

Instantly share code, notes, and snippets.

View figueroadavid's full-sized avatar

David Figueroa figueroadavid

View GitHub Profile
@figueroadavid
figueroadavid / Convert-QuserOutput.ps1
Created September 15, 2026 16:27
Convert QUser Output
function Convert-QUserOutput {
<#
.SYNOPSIS
Converts the output of quser.exe into a structured format.
.DESCRIPTION
This function takes the output of quser.exe and converts it into a structured format (pscustomobject)
for easier manipulation and analysis.
.EXAMPLE
Convert-QUserOutput | format-table -AutoSize
IsCurrent UserName SessionName SessionID State IdleTimeText IdleTime LogonDate
@figueroadavid
figueroadavid / Test-ADGroupLock.ps1
Created August 7, 2026 13:31
Test-ADGroupLock.ps1
function Test-ADGroupLock {
<#
.SYNOPSIS
The script will test the permissions of a group in Active Directory looking for the locking permissions set by Lock-ADGroup.
.DESCRIPTION
The script will enumerate the ACL of a group and look for 2 permissions and report the status:
1. Everyone:Deny on the WriteMembers Extended permission
2. Everyone:Deny on the members attribute of the group
@figueroadavid
figueroadavid / Unlock-ADGroup.ps1
Created August 7, 2026 13:31
Unlock-ADGroup.ps1
function Unlock-ADGroup {
<#
.SYNOPSIS
The script will "lock" the membership of a group in Active Directory
.DESCRIPTION
The script will modify the permissions of a group to remove permissions added by Lock-ADGroup.
.NOTES
The script does not depend on the ActiveDirectory module, and leverages the built in ADSI functionality of
Windows Powershell. 2 permissions are remove from the group.
1. Everyone:Deny on the WriteMembers Extended permission
@figueroadavid
figueroadavid / Lock-ADGroup.ps1
Created August 7, 2026 13:29
Lock-ADGroup.ps1
function Lock-ADGroup {
<#
.SYNOPSIS
The script will "lock" the membership of a group in Active Directory
.DESCRIPTION
The script will modify the permissions of a group to prevent anyone from adding users to a
specific group by adding Everyone:Deny permissions to the WriteMembers extended right, and the
members attribute of the group.
.NOTES
The script does not depend on the ActiveDirectory module, and leverages the built in ADSI functionality of
@figueroadavid
figueroadavid / Update-ADGroup.ps1
Created August 7, 2026 13:28
Update-ADGroup.ps1
function Update-ADGroup {
<#
.SYNOPSIS
The script can update a locked group, adding and removing members
.DESCRIPTION
This script is a companion to Lock-ADGroup, Unlock-ADGroup, and Test-ADGroup.
The script will back up existing permissions, add members, remove members, and then
restore the original permissions.
.NOTES
The script does not depend on the ActiveDirectory module, and leverages the built in ADSI functionality of
@figueroadavid
figueroadavid / Test-PrinterPorts.ps1
Last active August 7, 2026 12:37
Test-PrinterPorts.ps1
function Test-PrinterPorts {
<#
.SYNOPSIS
Tests the connectivity of TCP ports on specified printers.
.DESCRIPTION
This function tests the connectivity of TCP ports on specified printers, either by name or IP address.
The printers can be Windows printers, or OMPlus printers. The function uses a runspace pool to perform
the tests concurrently, with a configurable throttle limit.
.PARAMETER WindowsPrinterName
The names of the Windows printers to test.
@figueroadavid
figueroadavid / Test-WillowEPSStatus.ps1
Created March 13, 2026 13:28
Checks the status of the EPS Recovery script and emails the results to the administrator
#Requires -RunAsAdministrator
function Test-WillowEPSStatus {
<#
.SYNOPSIS
Sends an email showing the status of the Willow EPS servers based on the
WamEPSRecovery script
.DESCRIPTION
The script reads the WamEpsRecoveryConfig.xml file to determine the list of EPS servers,
retrieves the failover status and print-related service statuses from each server, and compiles
@figueroadavid
figueroadavid / Get-ShortPathName.ps1
Created August 29, 2024 15:41
pInvoke function to retrieve 8.3 shortnames in powershell
function Get-ShortPathName{
Param([string] $path)
$MethodDefinition = @'
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetShortPathNameW", SetLastError = true)]
public static extern int GetShortPathName(string pathName, System.Text.StringBuilder shortName, int cbShortName);
'@
$Kernel32 = Add-Type -MemberDefinition $MethodDefinition -Name 'Kernel32' -Namespace 'Win32' -PassThru
$shortPath = New-Object System.Text.StringBuilder(500)
@figueroadavid
figueroadavid / ConvertFrom-DHCPToStatic.ps1
Created March 6, 2024 19:56
Converts an existing DHCP address configuration to a local static IP configuration
function ConvertFrom-DHCPToStatic {
<#
.SYNOPSIS
This script takes an existing DHCP configuration and converts it to a static IP configuration
.DESCRIPTION
The script uses several functions to retrieve the necessary data from the existing configuration,
removes that configuration, and installs the new configuration.
.NOTES
This script was built with the idea that there will only be one "physical" NIC in the server that is up and
running when the script is run. It has not been tested in other scenarios
@figueroadavid
figueroadavid / Backup-ArbitraryPuttyKey.ps1
Created February 29, 2024 23:08
Backs up a user's registry keys for Putty out of HKEY_USERS
function Backup-ArbitraryWinSCPKey {
<#
.SYNOPSIS
This script backups a user's registry keys for WinSCP
.DESCRIPTION
Unlike the Backup-WinSCPKey, this script allows the user to backup an arbitrary user's
WinSCP key out of HKEY_USERS\<usersid>\Software\Martin Prikryl
.NOTES
This does require administrator rights, since the user will be delving into HKEY_USERS.
.PARAMETER SamAccountName