Skip to content

Instantly share code, notes, and snippets.

View RylandDeGregory's full-sized avatar
🎯
Focusing

Ryland RylandDeGregory

🎯
Focusing
View GitHub Profile
@RylandDeGregory
RylandDeGregory / Invoke-AzWebAppContainerWebhookUrl.ps1
Created April 2, 2024 23:13
Invoke Azure App Service Web App for Containers CI/CD webhook for docker container image re-pull/version update.
# https://learn.microsoft.com/en-us/azure/app-service/deploy-ci-cd-custom-container?tabs=private&pivots=container-linux#4-enable-cicd
$WebhookURL = ''
$Username = $WebhookURL.Split('https://').Split(':')[1].Split('@')[0]
$Password = $WebhookURL.Split('https://').Split(':')[2].Split('@')[0]
$Headers = @{ 'Authorization' = "Basic $([Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$Username`:$Password")))" }
Invoke-RestMethod -Method Post -Uri "https://$($WebhookURL.Split('@')[1])" -Headers $Headers -UserAgent 'powershell/1.0'
@RylandDeGregory
RylandDeGregory / parse_html_bsoup.py
Created April 1, 2024 14:31
Parse all text content from an HTML document using BeautifulSoup.
from bs4 import BeautifulSoup
# path to the local file
doc = "C:\\Users\\Ryland\\Desktop\\index.html"
# open the file in read mode
with open(doc, 'r') as f:
content = f.read()
# Initialize the object with the document
@RylandDeGregory
RylandDeGregory / Add-AzAppGatewayUMIandSSLCert.ps1
Created January 31, 2024 22:16
Associate an Azure App Gateway (v2) with a User Assigned Managed Identity and an Azure Key Vault SSL Certificate.
# Define variables
$ResourceGroupName = ''
$AppGatewayName = ''
$ManagedIdentityName = ''
$KeyVaultName = ''
$KeyVaultCertficateName = ''
# Get App Gateway and Managed Identity resource objects
$AppGateway = Get-AzApplicationGateway -Name $AppGatewayName -ResourceGroupName $ResourceGroupName
$ManagedIdentity = Get-AzUserAssignedIdentity -Name $ManagedIdentityName -ResourceGroupName $ResourceGroupName
@RylandDeGregory
RylandDeGregory / Set-AzOpenAIDeploymentQuota.ps1
Created January 28, 2024 00:29
Update the Tokens Per Minute (TPM) quota limit for all Azure OpenAI Services in a given Azure Subscription
$SubscriptionId = ''
$ModelName = 'gpt-35-turbo*'
$RGs = Get-AzResourceGroup
foreach ($RG in $RGs) {
Write-Output "Processing Resource Group $($RG.ResourceGroupName)"
$Accounts = Get-AzCognitiveServicesAccount -ResourceGroupName $RG.ResourceGroupName | Where-Object { $_.Properties.Endpoint -like '*openai.azure.com*' } | Select-Object -ExpandProperty CustomSubDomainName
foreach ($Acct in $Accounts) {
Write-Output "Processing OpenAI Account $($Acct)"
@RylandDeGregory
RylandDeGregory / Start-MgSPOLibraryDownload.ps1
Last active January 28, 2024 00:35
Recursively download all files from a SharePoint Document Library folder using the Microsoft Graph PowerShell SDK.
<#
.SYNOPSIS
This script will download all files from a specified SharePoint Document Library path.
.EXAMPLE
$ScriptParams = @{
SharePointTenant = 'mycompany.sharepoint.com'
SiteName = 'mysite/my subsite'
DocumentLibraryName = 'Documents'
DocumentLibraryPath = 'my directory/my subdirectory'
LastModifiedDate = (Get-Date '2024-01-01')
@RylandDeGregory
RylandDeGregory / CosmosDBNoSqlREST.ps1
Created November 11, 2023 14:12
Azure Cosmos DB (NoSQL API) REST operations using PowerShell.
function New-MasterKeyAuthorizationSignature {
<#
.SYNOPSIS
Generate Cosmos DB Master Key Authentication header for use with the NoSQL REST API.
.EXAMPLE
$AuthKeyParams = @{
Method = Post
ResourceId = "dbs/$DatabaseId/colls/$CollectionId"
Date = [DateTime]::UtcNow.ToString('r')
MasterKey = $MasterKey
@RylandDeGregory
RylandDeGregory / AzureTablesREST.ps1
Last active June 10, 2024 22:01
Azure Table Storage REST operations using PowerShell.
$StorageAccount = ''
$Table = ''
$PartitionKey = ''
$RowKey = ''
# Set Azure Table Storage request headers
$Date = [DateTime]::UtcNow.ToString('R')
$AzTableHeaders = @{
'Accept' = 'application/json;odata=nometadata'
'x-ms-version' = '2020-08-04'
@RylandDeGregory
RylandDeGregory / Start-ADDSAADUserMerge.ps1
Created April 13, 2023 19:28
Merge ADDS user with existing Azure AD user.
# Get the Immutable ID of the ADDS user
$Name = 'My Name'
$ADUser = Get-ADUser -Filter 'Name -like "*$Name*"'
$ImmutableId = [System.Convert]::ToBase64String($ADUser.ObjectGUID.tobytearray())
# Connect to Azure AD
Connect-AzureAD
# Remove the duplicated user from Azure AD that was created when the ADDS user was first synced
Remove-AzureADUser -ObjectId <duplicated AAD user ObjectId>
@RylandDeGregory
RylandDeGregory / Get-DataverseRecord.ps1
Created April 12, 2023 21:28
Connect to and query Dataverse from PowerShell
#requires -Version 5.1
# Install required module from PSGallery
Install-Module -Name Microsoft.Xrm.Tooling.CrmConnector.PowerShell
# Interactive Sign-in
$CRMConn = Get-CrmConnection -InteractiveMode
# Unattended Sign-in
$Cred = New-Object System.Management.Automation.PSCredential ($UserName, $(ConvertTo-SecureString -String $Password -AsPlainText -Force))
@RylandDeGregory
RylandDeGregory / New-EventHubEvent.ps1
Created March 21, 2023 15:40
Add custom event to Azure Event Hub using PowerShell
[Reflection.Assembly]::LoadWithPartialName('System.Web') | Out-Null
$HMAC = New-Object System.Security.Cryptography.HMACSHA256
$EventHubsNamespace = ''
$EventHubName = ''
$EventHubEndpoint = "$EventHubsNamespace.servicebus.windows.net/$EventHubName"
$AccessPolicyName = 'RootManageSharedAccessKey'
$AccessPolicyKey = ''
$SASExpirationTime = ([DateTimeOffset]::Now.ToUnixTimeSeconds()) + 3000