Last active
December 22, 2017 08:11
-
-
Save rasmusgude/e3a8e464b19cbc1b657fb5974aacaa59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# “One-liner” for easily querying the Azure Instance Metadata Service. | |
"network/interface/0/ipv4/ipAddress/0/publicIpAddress" | Tee-Object -Variable p | Out-Null ; Invoke-RestMethod -Headers @{"Metadata"="true"} -URI "http://169.254.169.254/metadata/instance/$($p)?api-version=2017-08-01&format=text" | |
# Instead of "network/interface/0/ipv4/ipAddress/0/publicIpAddress" you can use any | |
# path throgh the instance metadata json structure. | |
# You can find a sample json structure here: | |
# { | |
# "compute": { | |
# "location": "westus2", | |
# "name": "Win10", | |
# "offer": "Windows", | |
# "osType": "Windows", | |
# "placementGroupId": "", | |
# "platformFaultDomain": "0", | |
# "platformUpdateDomain": "0", | |
# "publisher": "MicrosoftVisualStudio", | |
# "resourceGroupName": "****", | |
# "sku": "Windows-10-N-x64", | |
# "subscriptionId": "****", | |
# "tags": "", | |
# "version": "2017.10.12", | |
# "vmId": "****", | |
# "vmSize": "Standard_B2s" | |
# }, | |
# "network": { | |
# "interface": [ | |
# { | |
# "ipv4": { | |
# "ipAddress": [ | |
# { | |
# "privateIpAddress": "10.1.2.4", | |
# "publicIpAddress": "51.143.***.***" | |
# } | |
# ], | |
# "subnet": [ | |
# { | |
# "address": "10.1.2.0", | |
# "prefix": "24" | |
# } | |
# ] | |
# }, | |
# "ipv6": { | |
# "ipAddress": [] | |
# }, | |
# "macAddress": "******" | |
# } | |
# ] | |
# } | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment