Remove-AzDnsRecordSet
Deletes a record set.
Syntax
Remove-AzDnsRecordSet
-Name <String>
-RecordType <RecordType>
-ZoneName <String>
-ResourceGroupName <String>
[-PassThru]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzDnsRecordSet
-Name <String>
-RecordType <RecordType>
-Zone <DnsZone>
[-PassThru]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzDnsRecordSet
-RecordSet <DnsRecordSet>
[-Overwrite]
[-PassThru]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Remove-AzDnsRecordSet cmdlet deletes the specified record set from the specified zone. You cannot delete SOA or name server (NS) records that are automatically created at the zone apex. You can pass a RecordSet object to this cmdlet by using the pipeline operator or as a parameter. To identify a record set by name and type without using a RecordSet object, you must pass the zone as a DnsZone object to this cmdlet by using the pipeline operator or as a parameter, or alternatively you can specify the ZoneName and ResourceGroupName parameters. You can use the Confirm parameter and $ConfirmPreference Windows PowerShell variable to control whether the cmdlet prompts you for confirmation. When specifying the record set using a RecordSet object, the record set is not deleted if it has been changed in Azure DNS since the local RecordSet object was retrieved. This provides protection for concurrent changes. You can suppress this by using the Overwrite parameter, which deletes the record set regardless of concurrent changes.
Examples
Example 1: Remove a record set
$RecordSet = Get-AzDnsRecordSet -Name "www" -ResourceGroupName "MyResourceGroup" -ZoneName "myzone.com"
Remove-AzDnsRecordSet -RecordSet $RecordSet
The first command gets the specified record set, and then stores it in the $RecordSet variable.The second command removes the record set in $RecordSet.
Example 2: Remove a record set and suppress all confirmation
$RecordSet = Get-AzDnsRecordSet -Name "www" -ZoneName "myzone.com" -ResourceGroupName "MyResourceGroup"
Remove-AzDnsRecordSet -RecordSet $RecordSet -Confirm:$False -Overwrite
# Alternatively, the record set can be removed as follows. In this case,
# because the record set is specified by name rather than by object, the
# Overwrite parameter is not applicable.
Remove-AzDnsRecordSet -Name "www" -ZoneName "myzone.com" -ResourceGroupName "MyResourceGroup" -Confirm:$False
The first command gets the specified record set. The second command deletes the record set, even if it has changed in the meantime. Confirmation prompts are suppressed.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Name
Specifies the name of the RecordSet to remove. When specifying the record set by name, the DNS zone must be specified using either the Zone parameter or the ZoneName and ResourceGroupName parameters. Alternatively, the record set can be specified using a RecordSet object, passed using the RecordSet parameter.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Overwrite
When specifying the record set using a RecordSet object, the record set is not deleted if it has been changed in Azure DNS since the local RecordSet object was retrieved. This provides protection for concurrent changes. This can be suppressed using the Overwrite parameter, which deletes the record set regardless of concurrent changes.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PassThru
passthru
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RecordSet
Specifies the RecordSet object to remove. Alternatively, the record set can be specified using the Name and Zone parameters, or using the Name, ZoneName, and ResourceGroupName parameters.
Type: | DnsRecordSet |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-RecordType
Specifies the type of DNS record. Valid values are:
- A
- AAAA
- CNAME
- MX
- NS
- PTR
- SRV
- TXT SOA records are deleted automatically when the zone is deleted. You cannot manually delete SOA records.
Type: | RecordType |
Accepted values: | A, Aaaa, CAA, Cname, MX, NS, PTR, SOA, SRV, TXT, Tlsa, DS, Naptr |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ResourceGroupName
Specifies the resource group that contains the DNS zone that contains the RecordSet to delete. This parameter is applicable only when the record set and DNS zone are specified using the Name and ZoneName parameters. Alternatively, you can specify the record set using either the RecordSet parameter, or the Name and Zone parameters.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Zone
Specifies the DNS zone that contains the RecordSet to delete. This parameter is applicable only when specifying the record set using the Name parameter. Alternatively, you can specify the record set using either the RecordSet parameter, or the Name, ZoneName, and ResourceGroupName parameters.
Type: | DnsZone |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ZoneName
Specifies the name of the zone that contains the RecordSet to delete. You must also specify the Name and ResourceGroupName parameters. Alternatively, the record set can be specified using either the RecordSet parameter, or the Name and Zone parameters.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Inputs
Outputs
Notes
You can use the Confirm parameter to control whether this cmdlet prompts you for confirmation. By default, the cmdlet prompts you for confirmation if the $ConfirmPreference Windows PowerShell variable has a value of Medium or lower. If you specify Confirm or Confirm:$True, this cmdlet prompts you for confirmation before it runs. If you specify Confirm:$False, the cmdlet does not prompt you for confirmation.