Skip to content

Instantly share code, notes, and snippets.

View JustinGrote's full-sized avatar

Justin Grote JustinGrote

View GitHub Profile
@JustinGrote
JustinGrote / Get-InstalledModuleFast.ps1
Last active October 9, 2024 16:04
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 August 25, 2024 10:34
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',
@JustinGrote
JustinGrote / New-JAzDataCollectionRule.ps1
Last active August 3, 2024 08:19
Create a Data Collection rule with embedded Ingestion DCRs
using namespace Microsoft.Azure.PowerShell.Cmdlets.Monitor.DataCollection.Models
using namespace System.Management.Automation
function New-JAzDataCollectionRule {
<#
.SYNOPSIS
Create a new Data Collection Rule in Azure Monitor. Uses 2023 API for direct DCRs
.NOTES
The MS Documentation on this sucks but the reference has a good example which is how I figured it out: https://learn.microsoft.com/en-us/rest/api/monitor/data-collection-rules/create?view=rest-monitor-2023-03-11&tabs=HTTP#create-or-update-data-collection-rule-with-embedded-ingestion-endpoints
#>