Skip to content

Latest commit

 

History

History
134 lines (101 loc) · 3.48 KB

Remove-AzVMDataDisk.md

File metadata and controls

134 lines (101 loc) · 3.48 KB
external help file Module Name ms.assetid online version schema
Microsoft.Azure.PowerShell.Cmdlets.Compute.dll-Help.xml
Az.Compute
D5943E9F-E4E6-4A1F-A144-44691CF32FC8
2.0.0

Remove-AzVMDataDisk

SYNOPSIS

Removes a data disk from a virtual machine.

SYNTAX

Remove-AzVMDataDisk [-VM] <PSVirtualMachine> [[-DataDiskNames] <String[]>]
 [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
 [<CommonParameters>]

DESCRIPTION

The Remove-AzVMDataDisk cmdlet removes a data disk from a virtual machine.

EXAMPLES

Example 1: Remove a data disk from a virtual machine

$VirtualMachine = Get-AzVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" 
Remove-AzVMDataDisk -VM $VirtualMachine -Name "Disk3"
Update-AzVM -ResourceGroupName "ResourceGroup11" -VM $VirtualMachine

The first command gets the virtual machine named VirtualMachine07 by using the Get-AzVM cmdlet. The command stores the virtual machine in the $VirtualMachine variable. The second command removes the data disk named Disk3 from the virtual machine stored in $VirtualMachine. The final command updates the state of the virtual machine stored in $VirtualMachine in ResourceGroup11.

PARAMETERS

-DataDiskNames

Specifies the names of one or more data disks that this cmdlet removes.

Type: System.String[]
Parameter Sets: (All)
Aliases: Name

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

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Parameter Sets: (All)
Aliases: AzContext, AzureRmContext, AzureCredential

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

-VM

Specifies the local virtual machine object from which to remove a data disk. To obtain a virtual machine object, use the Get-AzVM cmdlet.

Type: Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine
Parameter Sets: (All)
Aliases: VMProfile

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

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

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine

OUTPUTS

Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine

NOTES

RELATED LINKS

Add-AzVMDataDisk

Get-AzVM