Last active
December 20, 2021 17:36
-
-
Save pcgeek86/5a21ad3fe726ca25aa1f to your computer and use it in GitHub Desktop.
Azure Disk Objects :: Add a StorageAccount property
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
<# | |
Author: Trevor Sullivan | |
Date: 2015-03-29 | |
Description: Microsoft Azure Disk objects offer the full URL to the cloud-based VHD | |
however, the Storage Account name is not exposed independently. We can | |
use PowerShell's Add-Member command to parse the URL and offer up the | |
Storage Account as its own property on each Disk object. | |
#> | |
Select-AzureSubscription -SubscriptionName 'Visual Studio Ultimate with MSDN'; | |
# Add a dynamic "StorageAccount" property to each Azure Disk object | |
$AddMember = @{ | |
Name = 'StorageAccount'; | |
MemberType = 'ScriptProperty'; | |
Value = { | |
$null = $this.MediaLink -match 'https://(.*?)\.'; | |
$matches[1]; | |
}; | |
PassThru = $true; | |
} | |
Get-AzureDisk | Add-Member @AddMember | Group-Object -Property StorageAccount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment