Skip to content

Instantly share code, notes, and snippets.

View AspenForester's full-sized avatar

JB Lewis AspenForester

  • Hennepin County, MN, USA
  • Minnesota, USA
View GitHub Profile
@JustinGrote
JustinGrote / Watch-UBreakIFix.psm1
Last active May 15, 2025 20:32
UBreakIFix Monitor
function Watch-UBreakIFix ($TrackingCode) {
while ($true) {
$result = foreach ($code in $TrackingCode) {
$response = Invoke-RestMethod "https://www.ubreakifix.com/api/v1/tracker/info?code=$code"
$status = $response.work_orders.work_order_status
[PSCustomObject]@{
'Customer' = $response.customer.full_name
'Device' = $response.work_orders.device.device_type.name
'Fixer' = $response.user.email
'Status' = $status.name
@JustinGrote
JustinGrote / Start-MSIEmulator.ps1
Last active April 16, 2025 18:35
A Managed Identity Emulator for testing Managed Identities locally. Returns a token from your currently logged in Azure PowerShell context
#requires -Module Az.Accounts
$verbosePreference = 'continue'
function ConvertFrom-JWTtoken {
<#
.NOTES
Lovingly borrowed from: https://www.michev.info/blog/post/2140/decode-jwt-access-and-id-tokens-via-powershell
#>
[cmdletbinding()]
param([Parameter(Mandatory = $true)][string]$token)
@JustinGrote
JustinGrote / Trace-AICommand.ps1
Last active May 16, 2025 12:51
Trace-AICommand: Report the results and performance of any scriptblock to Azure Application Insights
#requires -version 7
#You can load this script with $(iwr https://tinyurl.com/TraceAICommand | iex)
using namespace Microsoft.ApplicationInsights
using namespace Microsoft.ApplicationInsights.Extensibility
using namespace Microsoft.ApplicationInsights.DataContracts
using namespace System.Management.Automation
using namespace System.Collections.Generic
using namespace System.Net
#Reference: https://docs.microsoft.com/en-us/azure/azure-monitor/app/console
@jdhitsolutions
jdhitsolutions / Make-Module.ps1
Last active March 10, 2022 02:42
My module generation code from my Chicago PowerShell presentation on July 31, 2020.
#requires -version 5.1
#requires -module PowerShellGet
<#
The function assumes you have git installed and use it for source control
This code contains hard-coded references for my environment. This file
is offered as educational and reference material. It will not run for you
without revision.
@sheldonhull
sheldonhull / measure-powershell-objects.ps1
Created July 13, 2020 19:48
[Aggregate PowerShell Objects] How to use measuring and grouping to calculate the group counts of a powershell object. This can be useful for preaggregation of totals before exporting to excel for example #powershell
$Companies = @(
[pscustomobject]@{CompanyName = 'Foo'; UserCount = 5 }
[pscustomobject]@{CompanyName = 'Foo1'; UserCount = 5 }
[pscustomobject]@{CompanyName = 'Foo'; UserCount = 2 }
[pscustomobject]@{CompanyName = 'Foo'; UserCount = 3 }
)
$CalculatedResults = $Companies | Group-Object CompanyName | ForEach-Object {
$i = $_
@brantb
brantb / Manifest.Tests.ps1
Last active October 17, 2017 17:54
Pester test suite for module manifest
$ModuleManifestName = 'MyModuleName.psd1'
$ModuleManifestPath = "$PSScriptRoot\..\$ModuleManifestName"
Describe 'Module Manifest Tests' {
# Test-ModuleManifest is slooooooow for some reason :(
It 'Passes Test-ModuleManifest' -Skip {
Test-ModuleManifest -Path $ModuleManifestPath
$? | Should Be $true
}
@Jaykul
Jaykul / Convert-CodeCoverage.ps1
Last active June 11, 2018 07:11
How we "compile" modules from source .ps1 files
function Convert-CodeCoverage {
<#
.SYNOPSIS
Convert the file name and line numbers from Pester code coverage of "optimized" modules to the source
.EXAMPLE
Invoke-Pester .\Tests -CodeCoverage (Get-ChildItem .\Output -Filter *.psm1).FullName -PassThru |
Convert-CodeCoverage -SourceRoot .\Source -Relative
Runs pester tests from a "Tests" subfolder against an optimized module in the "Output" folder,
piping the results through Convert-CodeCoverage to render the code coverage misses with the source paths.
@Jaykul
Jaykul / PowerShellGet.psm1
Last active December 15, 2020 08:12
PowerShell Gallery Module - Light
function Find-Module {
<#
.Synopsis
A wrapper for Invoke-RestMethod to search the PowerShell Gallery
.Description
In order to support wildcards, we build pretty complicated URLs,
and then we filter the results by title
#>
[CmdletBinding()]
param (
@dfinke
dfinke / Get-Snoverism.ps1
Created December 8, 2015 20:06
Wisdom form the Shellfather, Jeffrey Snover - via Don Jones
function Get-Snoverism {
(Invoke-WebRequest http://snoverisms.com/).images.src |
Where {$_ -match 'quotes'} |
Get-Random |
Where { start "http://snoverisms.com/$($_)" }
}