Skip to content

Instantly share code, notes, and snippets.

View jdhitsolutions's full-sized avatar

Jeff Hicks jdhitsolutions

View GitHub Profile
@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()]
@jdhitsolutions
jdhitsolutions / Answers.ps1
Last active July 5, 2024 23:17
Some suggested solutions to PowerShell puzzles originally posted at https://jdhitsolutions.com/blog/powershell/8128/powershell-puzzles-and-challenges/
# PowerShell Puzzles and Quick Challenges
Return "This is an interactive demo script file."
<#
The answers to these puzzles are not limited to one-line commands, although some might.
Most of these problems should be solved with no more than a lines of PowerShell code
that you would run interactively at a PowerShell prompt.
This is not a test of your scripting skills although you will find it easier to
@jdhitsolutions
jdhitsolutions / MorningReport.ps1
Last active July 5, 2024 23:16
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
#requires -version 5.1
<#
.Synopsis
Create System Report
.Description
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
jdhitsolutions / ProcessManager.ps1
Created June 24, 2022 17:18
This is a revised version of an AnyBox example.
#requires -version 5.1
#requires -RunasAdministrator
#requires -module AnyBox
# https://www.fresh2.dev/doc/anybox/
# this is a revised version of the example at https://github.com/fresh2dev/AnyBox/blob/main/Examples/Process-Mgr.ps1
Param([string]$Computername = $env:Computername)
$anybox = New-Object AnyBox.AnyBox
@jdhitsolutions
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.
#requires -version 7.2
Function Get-Status {
[cmdletbinding(DefaultParameterSetName = 'name')]
[alias("gst")]
Param(
[Parameter(
Position = 0,
ValueFromPipeline,
ValueFromPipelineByPropertyName,
@jdhitsolutions
jdhitsolutions / Get-HostPrivateData.ps1
Created August 23, 2022 14:58
A PowerShell set of functions for managing host private data
#requires -version 5.1
#Get-HostPrivateData.ps1
#for best results run these commands in a PowerShell console
Function Get-HostPrivateData {
[cmdletbinding()]
[outputtype("PSHostPrivateData")]
Param()
<#
@jdhitsolutions
jdhitsolutions / 1. PSUGInnSalzach
Last active July 5, 2024 23:14
Presentation material for PSUGInnSalzach 9 Nov 2023
return "This is a demo script file."
#demo.ps1
#about me
https://jdhitsolutions.github.io
#Module layout
psedit c:\scripts\new-project.ps1
. c:\scripts\new-project.ps1
Help New-PSProject
@jdhitsolutions
jdhitsolutions / Send-MastodonPost.ps1
Created December 21, 2022 20:19
A PowerShell function to post a Mastodon status.
#requires -version 5.1
<#
Based on a function from https://gist.github.com/dhmacher/2203582502c7ab13015db8f52e94da45
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
jdhitsolutions / ConvertTo-PSClass
Last active July 5, 2024 23:14
A PowerShell function to convert an object instance into a PowerShell class definition.
Function ConvertTo-PSClass {
[cmdletbinding()]
[outputType([String])]
Param(
[Parameter(Position = 0, Mandatory, ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[object]$InputObject,
[Parameter(Mandatory, HelpMessage = "Enter the name of your new class")]
[ValidatePattern("^\w+$")]
[string]$Name,
@jdhitsolutions
jdhitsolutions / Get-WinEventReport.ps1
Last active July 5, 2024 23:14
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.
#requires -version 7.2
#requires -module ThreadJob
if ($IsLinux -OR $IsMacOS) {
Return "$($PSStyle.foreground.red)This command requires a Windows platform.$($PSStyle.Reset)"
}
if ($host.name -ne "ConsoleHost") {
Return "$($PSStyle.foreground.red)Detected $($host.name). This command must be run from a PowerShell 7.x console prompt.$($PSStyle.Reset)"
}
Function Get-WinEventReport {