Remove-AzureVMImage
Remove-AzureVMImage
Parameter Set: Default Remove-AzureVMImage [-ImageName] <String> [-DeleteVHD] [ <CommonParameters>]
The Remove-AzureVMImage cmdlet removes an operating system image from the image repository.
By default, this cmdlet doesn’t delete the associated physical image blob from the storage account. To delete the associated VHD, use the -DeleteVHD parameter.
-DeleteVHD
When specified, the physical VHD image blob is deleted from the storage account.
Aliases | none |
Required? | false |
Position? | named |
Default Value | none |
Accept Pipeline Input? | false |
Accept Wildcard Characters? | false |
-ImageName<String>
Specifies the operating system image to remove from the image repository.
Aliases | none |
Required? | true |
Position? | 1 |
Default Value | none |
Accept Pipeline Input? | true (ByPropertyName) |
Accept Wildcard Characters? | false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
-------------- Example 1 --------------
This command removes the "MyOSImage" image from the image repository.
C:\PS>Remove-AzureVMImage -ImageName MyOSImage
-------------- Example 2 --------------
This command removes the "MyOSImage" image from the image repository and also deletes the physical VHD image from the storage account.
C:\PS>Remove-AzureVMImage -ImageName MyOSImage –DeleteVHD
-------------- Example 3 --------------
This command sets the subscription context and then removes all the images from the image repository whose Label includes “Beta”.
C:\PS>$subsId = <MySubscriptionID>C:\PS>$cert = Get-AzureCertificate cert:\LocalMachine\MY\<CertificateThumbprint>C:\PS>Get-AzureVMImage `| Where-Object {$_.Label -match "Beta" }` | Foreach-Object {Remove-AzureVMImage –ImageName $_.name }
Related topics