Skip to content

Instantly share code, notes, and snippets.

View JustinGrote's full-sized avatar

Justin Grote JustinGrote

View GitHub Profile
@JustinGrote
JustinGrote / Debug.Tests.ps1
Last active November 27, 2024 18:56
PowerShell Debugging Examples
Describe "Debugging Examples" {
It 'Labs get Treats' {
$recommendedTreat = & $PSScriptRoot/Get-DogTreat.ps1 -DogBreed 'Labrador' -SuperBugged
$recommendedTreat.Calories | Should -BeGreaterThan 0
}
}
@JustinGrote
JustinGrote / Get-InstalledModuleFast.ps1
Last active October 16, 2024 19:09
Get info about locally installed PowerShell modules
function Get-InstalledModuleFast {
param(
#Modules to filter for. Wildcards are supported.
[string]$Name,
#Path(s) to search for modules. Defaults to your PSModulePath paths
[string[]]$ModulePath = ($env:PSModulePath -split [System.IO.Path]::PathSeparator),
#Return all installed modules and not just the latest versions
[switch]$All
)
@JustinGrote
JustinGrote / Set-AsRepoRepository.ps1
Last active October 11, 2024 18:21
Rename and setup repos to be just Pull Request sources to an upstream repo
function Invoke-GhAction {
param(
$RepoName,
$Path,
$Method = 'GET',
$Body,
$BaseUri = 'https://api.github.com/repos'
)
$irmParams = @{
@JustinGrote
JustinGrote / New-AzureDeploy.psm1
Created September 10, 2024 21:16
Create Azure Deploy Links and Buttons Easily
function New-AzureDeploy {
<#
.SYNOPSIS
Creates an Azure Deploy Button link for a given ARM template.
#>
param(
#Path to the ARM json template file that is publicly hosted and accessible. This cannot be a bicep template.
[string]$Uri,
#Path to a UI Definition JSON file. https://aka.ms/masandbox to create one.
[string]$FormDefinitionUri
@JustinGrote
JustinGrote / Example.MD
Created September 6, 2024 07:38
Watch Container App Job Logs

image

@JustinGrote
JustinGrote / asimAuxiliaryTables.bicep
Last active December 10, 2024 11:14
Create Auxiliary Table equivalents to ASIM and Common Log Sentinel Tables
param workspaceName string
param logRetentionDays int = 90
param tableNames array = [
'ASimNetworkSessionLogs'
'ASimAuthenticationEventLogs'
'ASimWebSessionLogs'
'ASimAuditEventLogs'
'ASimDhcpEventLogs'
'ASimDnsActivityLogs'
'ASimFileEventLogs'
@JustinGrote
JustinGrote / Send-AzMonitorLog.psm1
Created August 21, 2024 13:39
PowerShell Azure Monitor Log Ingestion
using namespace System.Collections.Generic
using namespace System.Management.Automation
using namespace System.Text
Function Send-AzMonitorLog {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$Endpoint,
@JustinGrote
JustinGrote / Watch-UBreakIFix.psm1
Last active August 20, 2024 20:49
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 August 29, 2024 14:53
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)
#requires -module Az.Functions
function Write-CmdletError {
param($message, $cmdlet = $PSCmdlet)
$cmdlet.ThrowTerminatingError(
[Management.Automation.ErrorRecord]::new(
$message,
'CmdletError',
'InvalidArgument',