Remove-AzureVMImage

Removes an operating system image from the image repository.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Service Management APIs. See the Az PowerShell module for cmdlets to manage Azure Resource Manager resources.

Syntax

Remove-AzureVMImage
      [-ImageName] <String>
      [-DeleteVHD]
      [-Profile <AzureSMProfile>]
      [-InformationAction <ActionPreference>]
      [-InformationVariable <String>]
      [<CommonParameters>]

Description

The Remove-AzureVMImage cmdlet removes an operating system image from the image repository. By default, this cmdlet does not delete the associated physical image blob from the storage account. To delete the associated virtual hard drive (VHD), use the DeleteVHD parameter.

Examples

Example 1: Remove an image from the image repository

PS C:\> Remove-AzureVMImage -ImageName "Image001"

This command removes the image named Image001 from the image repository.

Example 2: Remove an image from the image repository and also the VHD

PS C:\> Remove-AzureVMImage -ImageName " Image001" -DeleteVHD

This command removes the image named Image001 from the image repository and also deletes the physical VHD image from the storage account.

Example 3: Set a subscription context and then remove all the images

PS C:\> $SubsId = &lt;MySubscriptionID&gt;
PS C:\> $Cert = Get-AzureCertificate cert:\LocalMachine\MY\&lt;CertificateThumbprint&gt;
PS C:\> Get-AzureVMImage `
| Where-Object {$_.Label -match "Beta" }`
| Foreach-Object {Remove-AzureVMImage -ImageName $_.name }

This command sets the subscription context and then removes all the images from the image repository whose Label includes the name Beta.

Parameters

-DeleteVHD

Indicates that this cmdlet deletes the physical VHD image blob from the storage account.

Type:SwitchParameter
Position:1
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ImageName

Specifies the operating system or virtual machine image to remove from the image repository.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-InformationAction

Specifies how this cmdlet responds to an information event.

The acceptable values for this parameter are:

  • Continue
  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Profile

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Type:AzureSMProfile
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False