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-PythonModuleDependencies.ps1
Last active November 13, 2024 03:37
Fetch and display PyPI dependencies for a specified Python module and version in a formatted table.
<#
.SYNOPSIS
This script retrieves dependency information for specified Python modules and versions from PyPI.
.DESCRIPTION
The `Get-PythonModuleDependencies` function fetches dependency details for multiple specified Python modules and versions by accessing the PyPI JSON metadata. The dependencies, if any, are displayed in a structured table format, showing the module name, operator, version, and any conditions. Additionally, the script outputs information about each main module and version being checked, along with URLs for the PyPI project and JSON metadata.
.PARAMETER ModuleNames
An array of Python module names to check for dependencies.
@blakedrumm
blakedrumm / Write-Console.ps1
Last active October 16, 2024 01:47
Enhance your PowerShell scripts with Write-Console for displaying messages with optional timestamps and customizable colors. Utilize dynamic rainbow mode to create colorful, segmented outputs where each character has a unique color, ensuring no consecutive duplicates. Improve readability and organization in your console applications effortlessly…
<#
.SYNOPSIS
Provides advanced console output functionality with customizable timestamps and colorization options.
.DESCRIPTION
This script contains the `Write-Console` function to enhance PowerShell console output.
It offers features such as customizable timestamps, colored text, and segmented messages with advanced formatting.
A "Rainbow" mode is included, which applies unique colors to each character, improving readability and visual organization.
.EXAMPLE
@blakedrumm
blakedrumm / Convert-NonEncryptedAutomationVariables.ps1
Last active November 20, 2024 08:17
PowerShell script to convert non-encrypted variables in an Azure Automation Account to encrypted variables. This script retrieves all variables in the Automation Account, checks if they are encrypted, and converts non-encrypted variables by re-creating them with encryption enabled.
<#
.SYNOPSIS
This script converts non-encrypted Automation Account variables to encrypted ones.
.DESCRIPTION
The script retrieves all variables from an Azure Automation Account and checks if they are encrypted. If any variables are not encrypted, it removes and re-creates the variable with encryption enabled. It outputs the status of each variable during the process.
.PARAMETER ResourceGroupName
The name of the Azure Resource Group containing the Automation Account.
@blakedrumm
blakedrumm / Get-AzureQuotaUsage.ps1
Created August 28, 2024 15:10
PowerShell script to gather Azure quota and usage data across various services, allowing for region and subscription customization.
<#
.SYNOPSIS
This script gathers Azure quota and usage data for various services like Virtual Machines, Managed Disks, Storage, Networking, etc., for a specified region and outputs the data.
Optionally, it exports the data to a CSV file.
.DESCRIPTION
The script connects to your Azure subscription and retrieves usage and quota information for multiple services such as Virtual Machines, Managed Disks, Storage, and Networking.
It sorts the data by usage percentage and displays it in a formatted table. If needed, the data can also be exported to a CSV file.
.PARAMETER Location
@blakedrumm
blakedrumm / Invoke-AzMaintenance.ps1
Last active August 15, 2024 16:04
PowerShell script to manage Azure VMs during maintenance events. The script processes webhook data to determine the maintenance event type and manages Azure VMs accordingly by stopping services in 'pre' mode and starting them in 'post' mode.
<#
.SYNOPSIS
This script manages Azure VMs during maintenance events by stopping and starting services based on the specified mode.
.DESCRIPTION
The script processes webhook data to determine the maintenance event type and manages Azure VMs accordingly. It stops services in 'pre' mode and starts them in 'post' mode.
.PARAMETER ScriptMode
Specifies the mode of the script. Valid values are 'Pre' and 'Post'.
@blakedrumm
blakedrumm / Install_linux_azcmagent-debug.sh
Created July 29, 2024 22:24
This Bash script automates the installation and configuration of the Azure Connected Machine Agent on various Linux distributions with detailed debugging and proxy support.
#!/bin/bash
#
# Copyright (c) Microsoft Corporation.
#
# This script will
# 1. Configure host machine to download from packages.microsoft.com
# 2. Install Azcmagent package
# 3. Configure for proxy operation (if specified on the command line)
#
# Note that this script is for Linux only
@blakedrumm
blakedrumm / Detect-PublicIps.ps1
Last active July 16, 2024 05:02
PowerShell script to list all virtual machines and their public IP addresses across all Azure subscriptions in a specified tenant, using Managed Identity for authentication.
<#
.SYNOPSIS
This script lists all virtual machines in each Azure subscription and displays their public IP addresses.
.DESCRIPTION
The script authenticates using Managed Identity, sets the context to a specified tenant, retrieves all subscriptions
in that tenant, and then lists all virtual machines in each subscription along with their public IP addresses if available.
.NOTES
Ensure that the Managed Identity has sufficient permissions to access subscriptions and resources.
@blakedrumm
blakedrumm / Get-RequiredPowerShellModules.ps1
Last active August 2, 2024 17:23
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 ([email protected])
# 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 ([email protected])
# 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"