Skip to content

Instantly share code, notes, and snippets.

View PlagueHO's full-sized avatar
😼
Working on Game Master Copilot using Semantic Kernel, Azure OpenAI and Blazor 8

Daniel Scott-Raynsford PlagueHO

😼
Working on Game Master Copilot using Semantic Kernel, Azure OpenAI and Blazor 8
View GitHub Profile
@PlagueHO
PlagueHO / Create-AksClusterAdminsAadGroup.ps1
Created August 8, 2020 04:05
Create AKS Cluster Admins Azure Active Directory Group
$clusterAdminGroupObjectIds = (New-AzADGroup `
-DisplayName "AksClusterAdmin" `
-MailNickname "AksClusterAdmin").Id
@PlagueHO
PlagueHO / Get-AzSqlElasticPoolMetric.ps1
Created June 16, 2020 00:01
Pull metrics from Azure SQL Elastic Pools
<#
.SYNOPSIS
Pull metrics from Azure SQL Elastic Pools.
.EXAMPLE
PS C:\> $metrics = Get-AzSqlElasticPoolMetric -Verbose
Get 'eDTU_used' and 'eDTU_limit' metrics averaged over
each hour for the last 7 days for every Azure SQL Elastic
Pool in all subscriptions.
@PlagueHO
PlagueHO / Get-AzSqlDatabaseMetrics.ps1
Last active June 14, 2020 21:39
Get Azure SQL Database metrics for all Azure SQL databases in all subscriptions
$VerbosePreference = 'Continue'
$timeGrain = '01:00:00'
# The datetime to start the assessment from
$startTime = ((Get-Date).AddDays(-7))
$result = @()
Get-AzSubscription | Foreach-Object {
$subscriptionName = $_.Name
$null = $_ | Select-AzSubscription
Write-Verbose -Message ('Pulling performance data for all SQL Servers in subcription {0}...' -f $subscriptionName)
@PlagueHO
PlagueHO / Get-AzStorageUsedCapacity.ps1
Created June 4, 2020 05:54
PowerShell script to return the total amount of Azure Blob Storage used across all subscriptions
$result = @()
$subscriptions = Get-AzSubscription | Foreach-Object {
$subscriptionName = $_.Name
$null = $_ | Select-AzSubscription
Get-AzStorageAccount | Foreach-Object {
$used = (Get-AzMetric -ResourceId $_.Id -MetricName 'UsedCapacity' -WarningAction SilentlyContinue).Data.Average
$result += @(
[PSCustomObject] @{
SubscriptionName = $subscriptionName
StorageAccountName = $_.StorageAccountName
@PlagueHO
PlagueHO / Restore-GitTagForDsc.ps1
Created January 6, 2020 08:01
Restores the Git Tags for DSC Community Resource modules that were backed up when running Convert-GetTagForDsc
<#
.SYNOPSIS
Restore a set of backed up Git tags from the backup file
created by Convert-GitTagForDsc.ps1 in the $ENV:Temp folder.
.PARAMETER BackupFile
The full path to the backup file created by Convert-GitTagForDsc.ps1.
.PARAMETER Remote
The name of the Git remote repository for your fork.
@PlagueHO
PlagueHO / Convert-GitTagForDsc.ps1
Last active January 6, 2020 08:49
Converts the Git Tags for DSC Community Resource modules to be compatible with updated CI process
<#
.SYNOPSIS
Convert Git tags to the format required by the DSC Resource module
CI Process.
.PARAMETER Remote
The name of the Git remote repository for your fork.
.PARAMETER Upstream
The name of the Git remote repository for the upstream fork.
@PlagueHO
PlagueHO / Get-AzMetadataServiceScheduledMaintenance.ps1
Created October 22, 2019 22:22
Get All Scheduled Maintenance Events for an Azure VM using the Azure Metadata Service
Invoke-RestMethod `
-Method GET `
-Uri 'http://169.254.169.254/metadata/scheduledevents?api-version=2017-11-01' `
-UseBasicParsing `
-Headers @{ 'Metadata' = 'true' }
@PlagueHO
PlagueHO / SelectAzureSubscriptionUsingAzCli.sh
Created October 10, 2019 22:53
Select a specific Azure subscription using Az CLI when more one subscription exists with the same account name
az account set --subscription (az account list --query "[?name=='Visual Studio Enterprise'].{Id:id}" -o tsv)
@PlagueHO
PlagueHO / Convert-ColourNameToColourValueEnumeratorTypeWithDefault.ps1
Created October 4, 2019 23:43
PowerShell example using an enumerator type to map colour name to value with a default value set for invalid values
$colourName = 'grey'
# Only needs to be declared once
enum colour {
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF
white = 0xFFFFFF
}
@PlagueHO
PlagueHO / Convert-ColourNameToColourValueEnumeratorType.ps1
Last active October 4, 2019 23:41
PowerShell example using an enumerator type to map colour name to value
$colourName = 'green'
# Only needs to be declared once
enum colour {
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF
white = 0xFFFFFF
}