Skip to content

Instantly share code, notes, and snippets.

@rasmusgude
Last active December 22, 2017 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasmusgude/eb4b6a4d9c6a3eea44e2e43e51ec5605 to your computer and use it in GitHub Desktop.
Save rasmusgude/eb4b6a4d9c6a3eea44e2e43e51ec5605 to your computer and use it in GitHub Desktop.
# Function for easily querying the Azure Instance Metadata Service
Function AzMeta {
Param( [Parameter(ValueFromPipeline)] $p )
Invoke-RestMethod `
-Headers @{"Metadata"="true"} `
-URI "http://169.254.169.254/metadata/instance/$($p)?api-version=2017-08-01&format=text"
}
# Get the public IP if your Azure instance
"network/interface/0/ipv4/ipAddress/0/publicIpAddress" | AzMeta
# Get the Virtual Machine Size/SKU, e.g. "Standard_B2s"
"compute/vmSize" | AzMeta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment