Skip to content

Instantly share code, notes, and snippets.

View GeorgeLeithead's full-sized avatar
🤩
Turning ideas into code, one commit at a time 💻✨

George Leithead GeorgeLeithead

🤩
Turning ideas into code, one commit at a time 💻✨
View GitHub Profile
@GeorgeLeithead
GeorgeLeithead / Get-CimNamespace.ps1
Created November 10, 2023 16:04 — forked from jdhitsolutions/Get-CimNamespace.ps1
A PowerShell function to enumerate WMI namespaces using the CIM cmdlets
#requires -version 4.0
Function Get-CimNamespace {
[cmdletbinding(DefaultParameterSetName = 'computer')]
Param(
[Parameter(Position=0)]
[ValidateNotNullorEmpty()]
[string]$Namespace = "Root",
[Parameter(ParameterSetName = 'computer')]
[ValidateNotNullorEmpty()]
@GeorgeLeithead
GeorgeLeithead / Invoke-SqlQuery.ps1
Created November 10, 2023 15:59 — forked from jdhitsolutions/Invoke-SqlQuery.ps1
A PowerShell script to invoke any T-SQL query against any SQL supported database. This does not use any of the SQL modules.
#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
@GeorgeLeithead
GeorgeLeithead / PSWho.ps1
Created November 10, 2023 15:58 — forked from jdhitsolutions/PSWho.ps1
A PowerShell function for getting user metadata. See help for more details.
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
@GeorgeLeithead
GeorgeLeithead / NetAdapterMonitor.ps1
Created November 10, 2023 15:54 — forked from jdhitsolutions/NetAdapterMonitor.ps1
A PowerShell script that creates a WPF-based form showing network adapter information.
#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.
@GeorgeLeithead
GeorgeLeithead / Find-Cimclass.ps1
Created November 10, 2023 15:53 — forked from jdhitsolutions/Find-Cimclass.ps1
A PowerShell function to search WMI for a specfic class using the CIM cmdlets.
#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()]
@GeorgeLeithead
GeorgeLeithead / Get-FSOFolderSize.ps1
Created November 10, 2023 15:53 — forked from jdhitsolutions/Get-FSOFolderSize.ps1
A PowerShell function using the Scripting.FileSystemObject COM object to get total size of a folder.
#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()]
@GeorgeLeithead
GeorgeLeithead / New-HTMLDiskReport.ps1
Created November 10, 2023 15:52 — forked from jdhitsolutions/New-HTMLDiskReport.ps1
A PowerShell function to create an html report showing drive utilization. Includes tooltip popup details and a color gradient.
#requires -version 3.0
Function New-HTMLDiskReport {
<#
.Synopsis
Create a disk utilization report with gradient coloring
.Description
This command will create an HTML report depicting drive utilization through a gradient color bar.
@GeorgeLeithead
GeorgeLeithead / Get-ProcessMemory.ps1
Created November 10, 2023 15:52 — forked from jdhitsolutions/Get-ProcessMemory.ps1
A PowerShell function to display a snapshot of process memory usage based on the workingset value. The file includes a format.ps1xml file.
Function Get-ProcessMemory {
<#
.SYNOPSIS
Get a snapshot of a process' memory usage.
.DESCRIPTION
Get a snapshot of a process' memory usage based on its workingset value. You can get the same information using Get-Process or by querying the Win32_Process WMI class with Get-CimInstance. This command uses Invoke-Command to gather the information remotely. Many of the parameters are from that cmdlet.
.EXAMPLE
PS C:\> get-processmemory code,powershell*
@GeorgeLeithead
GeorgeLeithead / Get-WindowsVersion.ps1
Created November 10, 2023 15:51 — forked from jdhitsolutions/Get-WindowsVersion.ps1
A set of PowerShell functions to remotely query the registry and get operating system version information.
Function Get-WindowsVersion {
<#
.SYNOPSIS
Get Windows version information
.DESCRIPTION
This is a PowerShell version of the winver.exe utility. This commands uses PowerShell remoting to query the registry on a remote machine to retrieve Windows version information.The parameters are the same as in Invoke-Command.
.PARAMETER Computername
Specifies the computers on which the command runs. The default is the local computer.
@GeorgeLeithead
GeorgeLeithead / Get-GitSize.ps1
Created November 10, 2023 15:51 — forked from jdhitsolutions/Get-GitSize.ps1
A PowerShell function to get the size and number of files in the hidden .git directory.
Function Get-GitSize {
<#
.SYNOPSIS
Get the size of .git folder
.DESCRIPTION
When using git, it creates a hidden folder for change tracking. Because the file is hidden it is easy to overlook how large it might become. This command provides a simple mechanism for calculating the size of the .git folder. Specify the parent folder path.
.PARAMETER Path
The path to the parent folder, not the .git folder.