Skip to content

Instantly share code, notes, and snippets.

@emrgcl
emrgcl / README.md
Last active September 27, 2025 08:56
Azure Arc SQL Server Upload Health Monitoring - ARM

Arc SQL Server Upload Health Monitoring ARM Template

Overview

This ARM template deploys an automated monitoring solution for Azure Arc-enabled SQL Servers. It monitors the health status of SQL Server data uploads to Azure and alerts when servers fail to upload metrics successfully.

image

What it Does

  • Monitors Arc-enabled SQL Server extensions (both Windows and Linux) for data upload status
@emrgcl
emrgcl / squid.conf
Created September 24, 2025 19:51
Configure Squid proxy
management.azure.com
login.microsoftonline.com
gbl.his.arc.azure.com
packages.microsoft.com
download.microsoft.com
@emrgcl
emrgcl / hyperv.yml
Created September 24, 2025 19:47
Using Powershell DSC within Winget
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
resources:
- resource: HyperVDsc/VMHyperV
id: ArcBox-Win2K25
directives:
description: Configure VM ArcBox-Win2K25
settings:
Name: ArcBox-Win2K25
@emrgcl
emrgcl / get-LAWorkspacesWithLegacyCollectionEnabled.ps1
Created December 11, 2024 11:57
Reports workspces with legacy data sources confgiured to be migrated to Azure Monitor Data Collection Rules
# Reports workspces with legacy data sources confgiured to be migrated to Azure Monitor Data Collection Rules
# set your tenant id
$TenantID = 'XXXX'
$Context = Connect-AzAccount -Tenant $TenantID
# Get the access token for the management API
$Token = (Get-AzAccessToken -ResourceUrl 'https://management.azure.com/').Token
$DataSourceKinds = @('WindowsEvent', 'WindowsPerformanceCounter', 'LinuxPerformanceObject','LinuxSyslog','IISLogs')
$Headers = @{Authorization = "Bearer $Token"}
@emrgcl
emrgcl / Remove-AzRoutes.ps1
Last active June 4, 2024 02:52
Remove routes from azure route table based on the regex pattern provided. Useful when cleaning up rotue tables. supports risk mitigation with whatif and confirm
# !!!!!!! Use with -whatif first to verify the the correct routes to be deleted. !!!!!!!
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = 'High'
)]
Param(
$TenantID = 'xxxxx-xxxxx-xxxx-xxxxx-xxxxx',
$Subscription = 'Subscription Name',
$RouteTable = 'RouteTable name',
@emrgcl
emrgcl / listen-port.ps1
Created May 16, 2024 06:57
listens port useful for firewall testing.
# Define the port number to listen on
# specify the port and run the script on your target server before installing server software, then from your client test the port connection.
param(
[int]$port = 7070
)
# Create a new TCP listener
$listener = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Any, $port)
# Start the listener
@emrgcl
emrgcl / set-localgatewayip.ps1
Last active May 11, 2024 11:41
sets the ip address of local gateway connection to the public ip where the script runs
# sets the ip address of local gateway connection to the public ip where the script runs. I use this script to update my lab connection to the dynamic public ip of my home router.
#requires -Modules Az.Accounts, Az.Network
# Specify the Resource Group Name and Gateway Name
$resourceGroupName = 'rg-con-prd-001'
$gatewayName = 'lng-con-vpn-001'
$TenantID= 'xxxxx'
$SubscriptionID = 'yyyyy'
# Requires Azure PowerShell module
@emrgcl
emrgcl / set-argentAMAproxy.ps1
Last active November 20, 2024 08:57
Set proxy for all azure monitor agents on all azure arc servers
# sets the proxy of all azure monitor agent for arc agents.
$ProxyAdress = "http://yourproxy:portnumber"
# the defaults settings below are for anonymous proxy authentication. Read the comments and set as necessary.
# leave the username and password as is if you dont use them.
$UserName = 'Username'
$PassWord = 'Password'
@emrgcl
emrgcl / write-eventlog.ps1
Created April 16, 2024 11:05
Creates and event in application event log with custom eventdata - data based on the Params.
$source = "xxxxz"
$Params = @("vvv","zzz")
$Message = "Something happend to {0}, and another thing happened to {1}" -f $Params[0],$Params[1]
$ResultantArray = @($Message)
$Params | ForEach-Object {
$ResultantArray += $_
}
if (![System.Diagnostics.EventLog]::SourceExists($source)) {
[System.Diagnostics.EventLog]::CreateEventSource($source, "Application")
@emrgcl
emrgcl / Get-ResoursoucesToMove.py
Created February 29, 2024 12:41
Getting resource inventory from terraform files and moving state of these resources
# run: python Get-ResoursoucesToMove.py <directory that includes tf files> <csvPath>
import os
import hcl2
import csv
import sys
# Check if the correct number of arguments is provided
if len(sys.argv) != 3:
print("Usage: python script_name.py <directory> <csvPath>")
sys.exit(1)