Skip to content

Instantly share code, notes, and snippets.

View jdhitsolutions's full-sized avatar

Jeff Hicks jdhitsolutions

View GitHub Profile
@jdhitsolutions
jdhitsolutions / license.txt
Last active December 1, 2025 22:32
Save and jump to recently used locations in PowerShell.
MIT License
Copyright (c) 2025 JDH Information Technology Solutions, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@jdhitsolutions
jdhitsolutions / Out-SelectFile.ps1
Last active December 1, 2025 22:04
Select files from a list generated by the pwshSpectreConsole module.
#requires -version 7.5
#requires -module pwshSpectreConsole
Function Out-SelectFile {
<#
.SYNOPSIS
Select files from a SpectreConsole list
.DESCRIPTION
Select files using Read-SpectreMultiSelection from the pwshSpectreConsole module. Selected objects will be written to the pipeline.
@jdhitsolutions
jdhitsolutions / Select-ToDelete.ps1
Last active December 1, 2025 21:55
Select files to delete in PowerShell. This requires the pwshSpectreConsole PowerShell module and PowerShell 7.
Empty File#requires -version 7.5
#requires -module pwshSpectreConsole
Function Select-ToDelete {
<#
.SYNOPSIS
Select files to delete.
.DESCRIPTION
Pipe files to this command which will use SpectreConsole to present a choice menu. The command has an automatic timeout of 15 seconds.
.PARAMETER InputObject
@jdhitsolutions
jdhitsolutions / Import-LocalModule.ps1
Last active December 1, 2025 21:54
Import a local module from a list. Requires PowerShell 7 and the pwshSpectreConsole module.
#requires -version 7.5
#requires -module pwshSpectreConsole
Function Import-LocalModule {
[cmdletbinding()]
[alias('ilm')]
Param(
[Parameter(Position = 0, HelpMessage = "The path to the module data JSON file")]
[ValidateScript({Test-Path $_})]
[string]$DataPath = "c:\scripts\LocalModuleData.json",
[switch]$Passthru
@jdhitsolutions
jdhitsolutions / Optimize-PSReadLineHistory.ps1
Last active December 1, 2025 19:00
A PowerShell command to trim the command history file used by PSReadline
#requires -version 5.0
#requires -module PSReadline
Function Optimize-PSReadLineHistory {
<#
.SYNOPSIS
Optimize the PSReadline history file
.DESCRIPTION
The PSReadline module can maintain a persistent command-line history. However, there are no provisions for managing the file. When the file gets very large, performance starting PowerShell can be affected. This command will trim the history file to a specified length as well as removing any duplicate entries.
.PARAMETER MaximumLineCount
@jdhitsolutions
jdhitsolutions / Show-Domain.ps1
Created February 15, 2021 15:06
A PowerShell script to display an Active Directory domain in colorized and tree form.
# requires -versoin 5.1
# requires -module ActiveDirectory
Function Show-DomainTree {
[cmdletbinding()]
[OutputType("String")]
[alias("dt")]
Param(
[Parameter(Position = 0, HelpMessage = "Specify the domain name. The default is the user domain.")]
[ValidateNotNullOrEmpty()]
[string]$Name = $env:USERDOMAIN,
@jdhitsolutions
jdhitsolutions / PSRefresh.ps1
Last active November 25, 2025 03:43
Refresh a new Windows PowerShell Installation.
#requires -version 5.1
#requires -RunAsAdministrator
#PSRefresh.ps1
<#
Update key PowerShell components on a new Windows 10/11 installation.
This script is not intended for server operating systems. The script
should be run in an interactive console session and not in a remoting session.
@jdhitsolutions
jdhitsolutions / Compare-File.ps1
Last active November 21, 2025 18:05
A PowerShell script alternative to Compare-Object for comparing text files. This should be considered a proof-of-concept.
#requires -version 7.2
<#
this is a variation of what you could do comparing text files
using Compare-Object. The only difference really is how this
script formats the output.
This should be considered a PROOF-OF-CONCEPT
#>
@jdhitsolutions
jdhitsolutions / New-HVHealthReport.ps1
Last active November 11, 2025 20:52
A PowerShell control script to create a heath report on a Hyper-V server and its virtual machines.
#requires -version 5.1
<#
.SYNOPSIS
Create an HTML Hyper-V health report.
.DESCRIPTION
This command will create an HTML-based Hyper-V health report. It is designed to report on Hyper-V 3.0 or later servers or even Client Hyper-V on Windows 10. This script will retrieve data using PowerShell remoting from the Hyper-V Host. It is assumed you will run this from your desktop and specify a remote Hyper-V host. You do not need any Hyper-V tools installed locally to run this script.
The report only shows virtual machine information for any virtual machine that is not powered off. If you include performance counters, you will only get data on counters with a value other than 0.
@jdhitsolutions
jdhitsolutions / ADChangeReport.ps1
Created January 27, 2021 18:23
A PowerShell script to create an HTML report on recent changes in Active Directory.
#requires -version 5.1
#requires -module ActiveDirectory,DNSClient
# https://jdhitsolutions.com/blog/powershell/8087/an-active-directory-change-report-from-powershell/
#Reporting on deleted items requires the Active Directory Recycle Bin feature
[cmdletbinding()]
Param(
[Parameter(Position = 0,HelpMessage = "Enter a last modified datetime for AD objects. The default is the last 4 hours.")]
[ValidateNotNullOrEmpty()]