< Back

Get-AzureUtilNonAttachedUnmanagedDisk

Sat Jan 11, 2020 12:18 pm

NAME Get-AzureUtilNonAttachedUnmanagedDisk



SYNOPSIS

Get the unmanaged disks (VHDs/Blobs) that non-attached to any virtual machines from the entire subscription.





SYNTAX

Get-AzureUtilNonAttachedUnmanagedDisk [[-ExcludeResourceGroup] <String[]>] [<CommonParameters>]





DESCRIPTION

Get the unmanaged disks (VHDs/Blobs) that non-attached to any virtual machines from the entire subscription.





PARAMETERS

-ExcludeResourceGroup <String[]>

This cmdlet is ignore the resource groups that provided by this parameter. This parameter is optional.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

System.Management.Automation.PSObject





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-AzureUtilNonAttachedUnmanagedDisk -Verbose



---- Example Description ----

In this example, it is to get the all non-attached unmanaged disks (VHDs/Blobs) in the current subscription.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-AzureUtilNonAttachedUnmanagedDisk -ExcludeResourceGroup 'TemplateStore-RG','securitydata' -Verbose



---- Example Description ----

In this example, it is to get the all non-attached unmanaged disks (VHDs/Blobs) in the current subscription except

the storage accounts in the "TemplateStore-RG" and "securitydata" resource groups.









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>$disks = Get-AzureUtilNonAttachedUnmanagedDisk -ExcludeResourceGroup 'securitydata'



PS C:\\>$disks | Format-Table -Property @{ Label = 'Resource Group'; Expression = { $_.ResourceGroupName } },

@{ Label = 'Storage Account'; Expression = { $_.StorageAccountName } },

@{ Label = 'Location'; Expression = { $_.Location } },

@{ Label = 'SKU'; Alignment = 'Left'; Expression = { $_.Sku.Name } },

@{ Label = 'Container'; Expression = { $_.ContainerName } },

@{ Label = 'VHD/Blob'; Expression = { $_.Name } },

@{ Label = 'Size (GB)'; Expression = { [int] ($_.Length / 1GB) } },

'LastModified'



Resource Group Storage Account Location SKU Container VHD/Blob Size (GB) LastModified

-------------- --------------- -------- --- --------- -------- --------- ------------

ProjectA-RG vm1sa1055 japaneast StandardLRS vhd datadisk1.vhd 127 5/6/2017 11:05:14 AM +00:00

ProjectB-RG vm2sa1310 japaneast StandardLRS vhd osdisk.vhd 127 5/5/2017 2:22:10 PM +00:00

Test-RG premsa japaneast PremiumLRS vhd osdisk.vhd 127 5/5/2017 3:52:45 PM +00:00



---- Example Description ----

In this example, it is to get the all non-attached unmanaged disks (VHDs/Blobs) in the current subscription except

the storage accounts in the "securitydata" resource group. The results is formatted as table style in this example.









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Get-AzureUtilNonAttachedUnmanagedDisk -ExcludeResourceGroup 'securitydata' -Verbose |

Remove-AzureStorageBlob -Verbose



---- Example Description ----

In this example, it is to remove the all non-attached unmanaged disks (VHDs/Blobs) in the current subscription

except the storage accounts in the "securitydata" resource group.











RELATED LINKS

PowerShell Gallery: https://www.powershellgallery.com/packages/AzureUtil/

GitHub: https://github.com/tksh164/AzureUtil-PowerShellModule

Get-AzureUtilNonAttachedManagedDisk

Get-AzureUtilEmptyResourceGroup