Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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