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 / Crescendo-Demo.ps1
Created May 8, 2024 20:13
A demonstration PowerShell script using the Crescendo commands to create a PowerShell module.
#requires -version 7.4
#requires -Module Microsoft.PowerShell.Crescendo
#this demo assumes you have copied the du.exe utility from Sysinternals to a folder in your path
#the name of the module to create
$ModuleName = "FolderUsage"
#the parent folder for the module
$ModulePath = "C:\temp"
@jdhitsolutions
jdhitsolutions / 1. PSUGInnSalzach
Last active May 1, 2024 06:37
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 / Get-Restart.ps1
Created May 7, 2021 18:54
A PowerShell function and format file to query the event log using Get-WinEvent for restart related events.
Function Get-Restart {
[cmdletbinding()]
[outputtype("RestartEvent")]
Param(
[Parameter(Position = 0, ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[Alias("CN")]
[string]$Computername = $env:COMPUTERNAME,
[Parameter(HelpMessage = "Find restart events since this date and time.")]
[ValidateNotNullOrEmpty()]
@jdhitsolutions
jdhitsolutions / Challenge.md
Last active April 7, 2024 11:39
PowerShell Podcast Scripting Challenge

PowerShell Podcast ScriptingChallenge

This is the PowerShell scripting challenge from my appearance on the PowerShell Podcast

Base Challenge

Using whatever tools and techniques you want, write a PowerShell function that will query the Issues section of a GitHub repository and create output showing the number of open issues by label and the percentage of all open issues. Remember that multiple labels may be used with an issue.

For example, if there are 54 open issues and the bug label is used 23 times,your output would show a count of 23 and a total percentage of 42.59 for the bug

@jdhitsolutions
jdhitsolutions / demo.ps1
Created April 4, 2024 13:35
Material from my RTPSUG presentation on writing better PowerShell code
return "This is a demo script file."
# Find Me: https://jdhitsolutions.github.io
# Any one can learn syntax and mechanics.
# Let's focus on the squishy bits - what you should write
# and what not to write
#region Essential rules
@jdhitsolutions
jdhitsolutions / Get-GPLink.ps1
Created January 18, 2021 16:47
A PowerShell function to list Group Policy links
@jdhitsolutions
jdhitsolutions / Get-GHIssueStats.ps1
Created March 7, 2024 17:59
My solution for the PowerShell Podcast scripting challenge to write PowerShell code to get GitHub issue statistics.
#requires -version 7.4
<#
This function requires the gh.exe command line tool.
You many encounter API rate restrictions under heavy use.
#>
#load the custom formatting file
Update-FormatData $PSScriptRoot\ghLabelStatus.format.ps1xml
@jdhitsolutions
jdhitsolutions / Get-PowerShellEngine
Created August 8, 2017 14:04
A PowerShell function to get information about the currently running PowerShell executable. Details are pulled from $PSVersionTable, $Host and the file object.
#Requires -version 4.0
Function Get-PowerShellEngine {
<#
.Synopsis
Get the path to the current PowerShell engine
.Description
Use this command to find the path to the PowerShell executable, or engine that is running your current session. The path for PowerShell 6 is different than previous versions.
The default is to provide the path only. But you can also get detailed information
@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,