Skip to content

Instantly share code, notes, and snippets.

resource "azurerm_virtual_machine_extension" "domjoin" {
name = "domjoin"
location = "${var.location}"
resource_group_name = "${var.image_resource_group}"
virtual_machine_name = "${var.prefix}"
publisher = "Microsoft.Compute"
type = "JsonADDomainExtension"
type_handler_version = "1.3"
# What the settings mean: https://docs.microsoft.com/en-us/windows/desktop/api/lmjoin/nf-lmjoin-netjoindomain
settings = <<SETTINGS
@PixelRobots
PixelRobots / nodeVersion-check
Created September 15, 2023 07:21
Resource Graph- get nodeVersion of AKS clusters
resources
| where type == "microsoft.containerservice/managedclusters"
| mv-expand agentpool=properties.agentPoolProfiles
| extend nodeVersion = tostring(agentpool.nodeImageVersion)
| where nodeVersion startswith "AKSUbuntu"
| extend nodePoolName = tostring(agentpool.name)
| project clusterName = name, tenantId, subscriptionId, nodePoolName, nodeVersion
SecurityEvent
| where EventID in (4625, 4624) and AccountType == 'User'
| summarize Attempts = count(), Failed = countif(EventID == 4625), Succeeded = countif(EventID == 4654) by Account
SecurityEvent
| where EventID == 4625
| extend Reason = case(
SubStatus == '0xc0000064', 'User name does not exist',
SubStatus == '0xc000005e', 'No logon servers available to service the logon request',
SubStatus == '0xc0000062', 'Account name is not properly formatted',
Perf
| where ObjectName == "Process" and CounterName == "% Processor Time"
| where InstanceName contains "dropbox"
| summarize Running_Instances = dcount(InstanceName) by Computer
let StartDate = datetime("2019-06-30 22:46:42");
let EndDate = datetime("2019-07-01 00:57:27");
Perf
| where TimeGenerated between(StartDate .. EndDate)
| where ObjectName == "Process" and CounterName == "% Processor Time"
#Log in to Azure account
Login-AzureRmAccount
#Get list of Azure Subscription ID's
$Subs = (get-AzureRMSubscription).ID
#Loop through the subscriptions to find all empty Resource Groups and store them in $EmptyRGs
ForEach ($sub in $Subs) {
Select-AzureRmSubscription -SubscriptionId $Sub
$AllRGs = (Get-AzureRmResourceGroup).ResourceGroupName
az k8s-extension create \
--resource-group rg-aks-pixelland-weu \
--cluster-name aks-pixelland-weu \
--name flux \
--extension-type microsoft.flux \
--cluster-type managedClusters \
--auto-upgrade-minor-version true \
--config toleration-keys="CriticalAddonsOnly=true:NoSchedule"
AZURE_SUBSCRIPTION_ID=$(az account show --query "id" --output tsv)
AZURE_NODE_RESOURCE_GROUP=$(az aks show --resource-group ${AZURE_RESOURCE_GROUP} --name ${NAME} --query "nodeResourceGroup" --output tsv)
AZURE_SERVICE_PRINCIPAL=$(az ad sp create-for-rbac --scopes /subscriptions/${AZURE_SUBSCRIPTION_ID}/resourceGroups/${AZURE_NODE_RESOURCE_GROUP} --role Contributor --output json --only-show-errors)
AZURE_TENANT_ID=$(echo ${AZURE_SERVICE_PRINCIPAL} | jq -r '.tenant')
AZURE_CLIENT_ID=$(echo ${AZURE_SERVICE_PRINCIPAL} | jq -r '.appId')
AZURE_CLIENT_SECRET=$(echo ${AZURE_SERVICE_PRINCIPAL} | jq -r '.password')
az aks get-credentials --resource-group rg-aks-byo-cni-dev --name aks-byo-cni-dev
helm install cilium cilium/cilium --version 1.11.3 \
@PixelRobots
PixelRobots / pixelrobots.json
Last active January 8, 2022 11:28
pixelrobots oh my posh theme
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"console_title": true,
"console_title_style": "template",
"console_title_template": "{{if .Root}}root :: {{end}}{{.Shell}} :: {{.Folder}}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
@PixelRobots
PixelRobots / capturehelmkubectloutput.ps1
Created October 26, 2021 13:14
capture helm and kubectl output to a variable
$command = $(helm uninstall me 2>&1)
if ($command -match 'error' ) {
write-host "error = $command" -ForegroundColor Red
}
$command = $(kubectl apply -f me.yaml 2>&1)
// enter a GB value to check
let setgbvalue = 100;
// Query
Perf
| where TimeGenerated > ago(1h)
| where ObjectName == "LogicalDisk" and CounterName == "Free Megabytes"
| where InstanceName !contains "D:"
| where InstanceName !contains "_Total"
| extend FreeSpaceGB = CounterValue/1024
| summarize FreeSpace = min(FreeSpaceGB) by Computer, InstanceName