Skip to content

Instantly share code, notes, and snippets.

View blakedrumm's full-sized avatar
🏠
Working from home

Blake Drumm blakedrumm

🏠
Working from home
View GitHub Profile
@blakedrumm
blakedrumm / Get-RequiredPowerShellModules.ps1
Created May 21, 2024 15:24
Identifies the required modules for a given PowerShell script by analyzing the cmdlets used within the script.
<#
.SYNOPSIS
Identifies the required modules for a given PowerShell script by analyzing the cmdlets used within the script.
.DESCRIPTION
The Get-RequiredModules function takes a script as input, extracts all the cmdlets used in the script, and determines which modules
these cmdlets belong to. It then returns a unique list of required modules.
.PARAMETER Script
The content of the PowerShell script to analyze for required modules.
@blakedrumm
blakedrumm / AzureMaintConfig_VMCount.ps1
Last active May 21, 2024 13:40
This PowerShell script retrieves Azure maintenance configurations, counts associated VMs, using Azure Maintenance and Resource Graph modules.
# This script retrieves maintenance configurations and the count of VMs associated with each configuration
# The script uses the Azure Maintenance and Azure Resource Graph modules
# Author: Blake Drumm (blakedrumm@microsoft.com)
# Date created: May 20th, 2024
# Original location: https://gist.github.com/blakedrumm/70abcf47d0e788d91a7f277d4590f122
# Import the required module
Import-Module Az.Maintenance
Import-Module Az.ResourceGraph
@blakedrumm
blakedrumm / Create-MaintenanceConfigManagerRole.ps1
Last active May 16, 2024 01:06
Script to create a custom role for managing Azure Maintenance Configurations.
# Create-MaintenanceConfigManagerRole.ps1
# Script to create a custom role for managing Azure Maintenance Configurations
# Author: Blake Drumm (blakedrumm@microsoft.com)
# Website: https://blakedrumm.com/blog/resolve-azure-maintenance-configuration-error/
# Date created: May 15th, 2024
# Date modified: May 15th, 2024
# Define custom variables
$subscriptionId = "a1b2c3d4-5e6f-7g8h-9i0j-1k2l3m4n5o6p"
$resourceGroupName = "ResourceGroupName"
@blakedrumm
blakedrumm / Get-AzRoleAssignmentReport.ps1
Last active April 30, 2024 21:40
This PowerShell script generates a report on Azure subscription user roles, groups, and their memberships, and then emails this report as an attachment. It logs into Azure using a managed identity, fetches role assignments for given subscriptions, compiles them into a report, and mails this report to specified recipients. The script uses the .NE…
<#
.SYNOPSIS
Sends detailed reports on Azure Users, Groups, and Roles via email.
.DESCRIPTION
This PowerShell script generates a report on Azure subscription user roles, groups, and their memberships, and then emails this report as an attachment. It logs into Azure
using a managed identity, fetches role assignments for given subscriptions, compiles them into a report, and mails this report to specified recipients. The script uses
the .NET Mail API for secure email transmission.
.PARAMETER EmailUsername
@blakedrumm
blakedrumm / Run-AzureArcCommand.ps1
Last active April 9, 2024 04:02
This script allows you to run a command on an Azure Arc machine using the API.
# ============================================================================
# Name: Run command on Azure Arc machine
# ============================================================================
# Author: Blake Drumm (blakedrumm@microsoft.com)
# Website: https://blakedrumm.com/
# Date created: April 4th, 2024
# ============================================================================
$AzureRmContext = Connect-AzAccount
@blakedrumm
blakedrumm / Get-SCOM2019CatalogLatestUpdate.ps1
Created March 27, 2024 23:50
This script allows you to gather the latest update for SCOM 2019 and output to a table for an email let you know if there are updates.
# Author: Blake Drumm (blakedrumm@microsoft.com)
# Date Created: March 27th, 2024
# Website: https://blakedrumm.com/
# Define the HTML content or URL
$url = "https://www.catalog.update.microsoft.com/Search.aspx?q=System+Center+2019+-+Operations+Manager"
try {
# Get the HTML content of the webpage
$htmlContent = Invoke-WebRequest -Uri $url
@blakedrumm
blakedrumm / Toggle-VMPowerByTag.ps1
Last active April 17, 2024 03:27
This script will toggle the Powerstate for VM's inside of Subscription(s) with specific tags.
param
(
[Parameter(Mandatory = $true)]
[String[]]$SubscriptionIds,
[Parameter(Mandatory = $true)]
[String]$TagName,
[Parameter(Mandatory = $true)]
[String]$TagValue,
[Parameter(Mandatory = $true)]
[Boolean]$PowerState, # true for start, false for stop
@blakedrumm
blakedrumm / Get-PSInstalledModulesScope.ps1
Last active March 26, 2024 19:39
This grabs the Name, Version, Scope, and InstalledLocation.
# Author: Blake Drumm (blakedrumm@microsoft.com)
# Created: March 26th, 2024
# Retrieve PSModulePath
$modulePaths = $env:PSModulePath -split ';'
# Retrieve all installed modules
$installedModules = Get-Module -ListAvailable
if ($installedModules) {
@blakedrumm
blakedrumm / Gather_AzureArc_Version.kql
Created February 28, 2024 00:26
An Azure Resource Graph query to efficiently map and manage microsoft.hybridcompute/machines with detailed insights on OS versions, agent details, and provisioning statuses for improved infrastructure oversight.
/*
Author: Blake Drumm (blakedrumm@microsoft.com)
Date Created: February 27th, 2024
Description:
Azure Resource Graph query for enhanced inventory management of microsoft.hybridcompute/machines,
detailing essential attributes such as display names, operating system versions with friendly names for Windows 11,
Windows 10, and various Windows Server releases, agent version, automatic upgrade capability, provisioning state,
and ESU license status. By using regular expressions for accurate OS version categorization, it offers administrators
and support teams a powerful tool for comprehensive oversight and management of hybrid computing environments,
facilitating effective upgrade planning, compliance monitoring, and support tasks.
@blakedrumm
blakedrumm / Retrieve-MicrosoftDownloadInfo.ps1
Last active February 28, 2024 00:37
Automate Microsoft download details extraction effortlessly with this PowerShell script. Retrieve title, version, release date, and URL information using provided IDs.
<#
Author: Blake Drumm (blakedrumm@microsoft.com)
Date Created: February 27th, 2024
Description:
This PowerShell script automates the extraction of key details like title, version, release date, and URL for Microsoft downloads based on provided IDs.
By utilizing web scraping methods, it facilitates the seamless retrieval and organization of essential information from Microsoft's download pages.
#>
$FinalOutput = @()
$x = 0