- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to retrieve the Azure VM Subscription Name using PowerShell?
Once you are connected to the Azure Account, there are possibilities that the Get-AzVM will display the VMs from all the Azure Subscriptions.
To find the specific Azure VM Subscription name, we will first retrieve the details of the VM using the Get-AzVM and it has an ID property that contains the Subscription ID and from the subscription ID property, we can retrieve the name of the Azure Subscription Name.
PS C:\> $azvm = Get-AzVM -Name TestMachine2k16 PS C:\> $subid = ($azvm.Id -split '/')[2] PS C:\> (Get-AzSubscription -SubscriptionId $subid).Name
The above will retrieve the name of the subscription.
Advertisements