Suppose I have a Virtual Machine provisioned in Azure running Windows Server 2016 standard Azure image.
Without installing anything onto the VM, how can I retrieve the details of the current VM using PowerShell from inside the VM?
Some properties I would like to retrieve are:
- VM name
- VM IP address
- Subscription ID
- VM location
I believe this is possible because the Windows Desktop image in Azure automatically shows most of the above information. So how can I get this information programmatically through PowerShell?
(As usual, Microsoft documentation live up to their reputation of no value)
Any help would be greatly appreciated.
I suggest you to use either Azure Instance Metadata Service
or Resource Graph
Run PowerShell scripts in your Windows VM by using Run Command, more detail here