Skip to content

Instantly share code, notes, and snippets.

View MudraR's full-sized avatar

Mudra Rawal MudraR

View GitHub Profile
@MudraR
MudraR / k3s-win10.sh
Created January 25, 2026 11:26
Install K3s on WSL (Windows 10)
# on WSL, run the following sh.
# https://github.com/k3s-io/k3s?tab=readme-ov-file#quick-start---install-script
curl -sfL https://get.k3s.io | sh -
# https://devops.stackexchange.com/questions/16043/error-error-loading-config-file-etc-rancher-k3s-k3s-yaml-open-etc-rancher
mkdir ~/.kube 2> /dev/null
sudo k3s kubectl config view --raw > "$KUBECONFIG"
chmod 600 "$KUBECONFIG"
@MudraR
MudraR / parameter-is-incorrect-cert-report.ps1
Created November 3, 2025 16:06
Analyze Certificates throwing "Parameter is incorrect" error during install
$thumbprintList = @(
'CERTIFICATETHUMBPRINT',
'CERTIFICATETHUMBPRINT2'
)
$report = foreach ($thumbprint in $thumbprintList) {
$cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Thumbprint -eq $thumbprint }
if ($cert) {
$key = [Security.Cryptography.X509Certificates.RSACertificateExtensions]::GetRSAPrivateKey($cert)
$file = Get-ChildItem -Path 'C:\ProgramData\Application Data\Microsoft\Crypto' -Recurse -Filter $key.key.UniqueName
[pscustomobject]@{
@MudraR
MudraR / match-public-key.ps1
Created July 17, 2025 12:48
Matching renewed certificates (from GoDaddy) by public key (for when CN is the same)
# Get all .crt certificates, excluding those with 'bundle' in the name
$crtCerts = Get-ChildItem -Path . -Recurse -Filter *.crt | Where-Object { $_.Name -notmatch 'bundle' } | ForEach-Object {
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($_.FullName)
[PSCustomObject]@{
FileName = $_.Name
Subject = $cert.Subject
SerialNumber = $cert.SerialNumber
Thumbprint = $cert.Thumbprint
PublicKey = $cert.GetPublicKeyString()
}
@MudraR
MudraR / push-custom-info.ps1
Created April 15, 2025 14:54
Push Custom Info to Dynatrace (PowerShell)
$token = "" # DT Token
$hostname = hostname
$processName = "process-name" #replace process name #by default is an IIS app pool
$headers = @{
"Authorization" = "Api-Token $token"
}
# Proprerties you want to log
$customObject = @{
@MudraR
MudraR / exampleAppServiceForLoop.bicep
Created December 6, 2024 13:56
[Bicep] Create App Services Using For Loop
# Quick Working POC using for loops in bicep to create an App Service Plan and AppServices from an array.
# https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/loops
@description('The Azure region into which the resources should be deployed.')
param location string = 'southcentralus'
@description('app services to provision')
param appServiceAppNames array = [
'App1'
@MudraR
MudraR / manageGitHubRepoEnvironment.sh
Created December 3, 2024 08:34
[GitHub Enterprise Repos] Create GitHub Deployment Environment
# Get team id:
# https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#get-a-team-by-name
# Create new deployment environment and protect it
gh api \
--method PUT \
repos/ORG/REPO/environments/NEW_ENV \
-f "reviewers[][type]=Team" -F "reviewers[][id]=TEAMID"
# Remove team from deployment environment
@MudraR
MudraR / testConnectionString.ps1
Last active November 25, 2024 17:09
[MicrosoftSQL Server] Test SQL Connection String
# Test-SQLConnection "Data Source=localhost,1433;database=myDB;User ID=myUser;Password=myPassword;"
function Test-SQLConnection {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string] $ConnectionString
)
process {
@MudraR
MudraR / webRequestTryCatch.ps1
Created November 21, 2024 17:01
Get Detailed Web Response via PowerShell
$Url = "https://google.com"
try {
$response = Invoke-WebRequest $Url -UseBasicParsing -UseDefaultCredentials
$statusCode = $response.StatusCode
$responseContent = $response.Content
$responseHeaders = $response.Headers
$responseRawContent = $response.RawContent
$responseAllProperties = $response | Select-Object *
} catch {
@MudraR
MudraR / getAKSServiceCIDR.ps1
Created November 20, 2024 14:32
Get Service CIDR of an AKS instance
# get Service CIDR
az account set --subscription $subscriptionId
$aksInfo = az aks show -g $aksResourceGroup -n $aksInstanceName | ConvertFrom-Json
$aksInfo.networkProfile.serviceCidrs
@MudraR
MudraR / getAGCipherSuites.ps1
Created November 20, 2024 14:30
Get Cipher Suites and SSL policy of an Azure Application Gateway
# get Cipher Suites and min protocol version
az account set --subscription $subscriptionId
$sslPolicy = az network application-gateway show -n $applicationGateway --resource-group $agResourceGroup | convertFrom-Json
az network application-gateway ssl-policy predefined show -n $sslPolicy.defaultPredefinedSslPolicy