Skip to content

Instantly share code, notes, and snippets.

@AlexanderHolmeset
Created May 20, 2025 10:28
Show Gist options
  • Save AlexanderHolmeset/377dac36ca618899115f204ef830f17a to your computer and use it in GitHub Desktop.
Save AlexanderHolmeset/377dac36ca618899115f204ef830f17a to your computer and use it in GitHub Desktop.
# This script will get all VMs with the guest OS "Windows Server" and send the details to a webhook URL in JSON format.
$VMs = get-vm | Where-Object{$_.guest -match "Windows Server"} |Select-Object -Property Name,Guest,CreateDate
# Convert the VM details to JSON format
$body = $VMs | ConvertTo-Json
$webhookURI = "Enter your webhook URL here"
# Send the JSON data to the webhook URL for the Azure Automation runbook
Invoke-WebRequest -Method Post -Uri $webhookURI -Body $body -UseBasicParsing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment