Skip to content

Instantly share code, notes, and snippets.

View jdhitsolutions's full-sized avatar

Jeff Hicks jdhitsolutions

View GitHub Profile
@jdhitsolutions
jdhitsolutions / Challenge.md
Last active December 5, 2023 21:32
PowerShell Podcast Scripting Challenge
View Challenge.md

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 / PowerShellLab_Setup.md
Last active December 4, 2023 05:43
Detailed instructions for setting up the PowerShellLab for my Pluralsight courses.
View PowerShellLab_Setup.md

PowerShell Lab Detailed Setup Instructions

For my Pluralsight PowerShell courses, you are welcome to use any lab environment you wish. It should include an Active Directory domain with at least a domain controller, a Windows 10 client, and a Windows Server 2016 or 2019 member server. You will need to modify the course files to fit your environment. At this point in time, Windows Server 2022 remains untested for my labs.

However, I am going to recommend that you use a free PowerShell module called PSAutoLab. I encourag you to look at the README document on the project's Github repository before proceeding. If you need help with the module or its commands, you will use the repository's Issue section.

PSAutolab

Please refer to this document to assist in installing and setting up the PSAutolab module on your computer. Run all commands from an elevated Windows PowerShell

@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.
View Show-Domain.ps1
# 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 / Get-GPLink.ps1
Created January 18, 2021 16:47
A PowerShell function to list Group Policy links
View Get-GPLink.ps1
@jdhitsolutions
jdhitsolutions / Get-CimNamespace.ps1
Created May 5, 2017 12:28
A PowerShell function to enumerate WMI namespaces using the CIM cmdlets
View Get-CimNamespace.ps1
#requires -version 4.0
Function Get-CimNamespace {
[cmdletbinding(DefaultParameterSetName = 'computer')]
Param(
[Parameter(Position=0)]
[ValidateNotNullorEmpty()]
[string]$Namespace = "Root",
[Parameter(ParameterSetName = 'computer')]
[ValidateNotNullorEmpty()]
@jdhitsolutions
jdhitsolutions / Invoke-SqlQuery.ps1
Created July 21, 2017 20:08
A PowerShell script to invoke any T-SQL query against any SQL supported database. This does not use any of the SQL modules.
View Invoke-SqlQuery.ps1
#requires -version 5.0
<#
.SYNOPSIS
Invoke any T-SQL query against any SQL supported database.
.DESCRIPTION
This command uses the .NET SqlClient classes to connect to a SQL database and execute any type of query. The default behavior is to use integrated Windows authentication, but you can pass a credential object for a username and password. This works well when run on Linux.
When you run a SELECT query the command will write a custom object for each row to the pipeline.
.PARAMETER Query
@jdhitsolutions
jdhitsolutions / PSWho.ps1
Last active November 10, 2023 15:58
A PowerShell function for getting user metadata. See help for more details.
View PSWho.ps1
Function Get-PSWho {
<#
.SYNOPSIS
Get PowerShell user summary information
.DESCRIPTION
This command will provide a summary of relevant information for the current
user in a PowerShell session. You might use this to troubleshoot an end-user
problem running a script or command. The default behavior is to write an
object to the pipeline, but you can use the -AsString parameter to force the
@jdhitsolutions
jdhitsolutions / NetAdapterMonitor.ps1
Last active November 10, 2023 15:54
A PowerShell script that creates a WPF-based form showing network adapter information.
View NetAdapterMonitor.ps1
#requires -version 5.0
#requires -module nettcpip,cimcmdlets
<#
This script will generate a WPF form to display network adapter
information. It will automatically refresh every 30 seconds.
You can change the interval then click the Update button.
I don't recommend refreshing any faster than 10 seconds. It can take almost
5 seconds to get all the network adapter information.
@jdhitsolutions
jdhitsolutions / Find-Cimclass.ps1
Last active November 10, 2023 15:53
A PowerShell function to search WMI for a specfic class using the CIM cmdlets.
View Find-Cimclass.ps1
#requires -version 4.0
#search WMI for a class
Function Find-CimClass {
[CmdletBinding()]
[OutputType([Microsoft.Management.Infrastructure.CimClass])]
Param(
[Parameter(Position = 0, Mandatory, HelpMessage = "Enter the name of a CIM/WMI class. Wildcards are permitted.")]
[ValidateNotNullOrEmpty()]
@jdhitsolutions
jdhitsolutions / Get-FSOFolderSize.ps1
Created October 5, 2018 21:28
A PowerShell function using the Scripting.FileSystemObject COM object to get total size of a folder.
View Get-FSOFolderSize.ps1
#the folder size includes hidden files
Function Get-FSOFolderSize {
[cmdletbinding()]
[OutputType("PSCustomObject")]
param(
[Parameter(Position = 0, Mandatory, HelpMessage = "Enter a filesystem path like C:\Scripts. Do not specify a directory root.")]
[ValidateNotNullOrEmpty()]