Skip to content

Instantly share code, notes, and snippets.


Jeff Hicks jdhitsolutions

View GitHub Profile
jdhitsolutions / rtpsug-advparameters.ps1
Created April 6, 2023 03:19
The demonstration file from my presentation for the Research Triangle PowerShell User Group on advanced function parameters.
View rtpsug-advparameters.ps1
#requires -version 7.3
No code in this file should be considered production-ready.
All code and explanations should be viewed as educational material.
You are free to re-use anything in this file in your own work.
jdhitsolutions / Send-MastodonPost.ps1
Created December 21, 2022 20:19
A PowerShell function to post a Mastodon status.
View Send-MastodonPost.ps1
#requires -version 5.1
Based on a function from
You need an access token that has at least write access to your status
* go to settings -> Development
* Click "New Application"
* Enter a name
jdhitsolutions / set-envvar.ps1
Last active January 29, 2023 22:39
Set a temporary environment variable in PowerShell
View set-envvar.ps1
#requires -version 5.1
#set a temporary environment variable
# example using the function alias and positional parameters: se rust_log debug
Function Set-EnvironmentVariable {
Param (
[Parameter(Position = 0, Mandatory)]
jdhitsolutions / ConvertTo-PSClass
Last active November 8, 2022 12:29
A PowerShell function to convert an object instance into a PowerShell class definition.
View ConvertTo-PSClass
Function ConvertTo-PSClass {
[Parameter(Position = 0, Mandatory, ValueFromPipeline)]
[Parameter(Mandatory, HelpMessage = "Enter the name of your new class")]
jdhitsolutions / Get-WinEventReport.ps1
Last active January 31, 2023 15:39
A PowerShell 7 function and custom format file to analyze an event log and report on error sources. Put both files in the same folder. Dot source the ps1 file.
View Get-WinEventReport.ps1
#requires -version 7.2
#requires -module ThreadJob
if ($IsLinux -OR $IsMacOS) {
Return "$($ command requires a Windows platform.$($PSStyle.Reset)"
if ($ -ne "ConsoleHost") {
Return "$($ $($ This command must be run from a PowerShell 7.x console prompt.$($PSStyle.Reset)"
Function Get-WinEventReport {
jdhitsolutions / Get-Status.ps1
Created August 23, 2022 21:41
A demonstration PowerShell 7 function using $PSStyle as default formatting. Put both files in the same folder. Dot source the ps1 file.
View Get-Status.ps1
#requires -version 7.2
Function Get-Status {
[cmdletbinding(DefaultParameterSetName = 'name')]
Position = 0,
jdhitsolutions / Get-HostPrivateData.ps1
Created August 23, 2022 14:58
A PowerShell set of functions for managing host private data
View Get-HostPrivateData.ps1
#requires -version 5.1
#for best results run these commands in a PowerShell console
Function Get-HostPrivateData {
jdhitsolutions / ProcessManager.ps1
Created June 24, 2022 17:18
This is a revised version of an AnyBox example.
View ProcessManager.ps1
#requires -version 5.1
#requires -RunasAdministrator
#requires -module AnyBox
# this is a revised version of the example at
Param([string]$Computername = $env:Computername)
$anybox = New-Object AnyBox.AnyBox
jdhitsolutions / MorningReport.ps1
Last active August 23, 2022 17:54
A PowerShell script to create a computer status report. In addition to the native object output, you can format the output as text or html. Read the help and examples
View MorningReport.ps1
#requires -version 5.1
Create System Report
Create a system status report with information gathered from WMI using Get-CimInstanxce. T
he default output to the pipeline is a collection of custom objects. You can also use -TEXT
to write a formatted text report, suitable for sending to a file or printer, or -HTML to
jdhitsolutions / rtpsug-ps7-demo.ps1
Last active February 2, 2022 21:03
This is my demo file from my RTPSUG on PowerShell 7.
View rtpsug-ps7-demo.ps1
#requires -version 7.1.2
Return "This is a walk-through demo script file"
#region demo prep
# Are you running in PowerShell 7?
#make my errors easier to read
$host.PrivateData.ErrorForegroundColor = "yellow"
#clear any default settings