Azure DNSZonePowershell

Good Morning

I need some help. I am a student and learning powershell. I need some assitance or training with parameters.

I need to create a small script that will check if dnszone is created if it is not then create it

I have done this so far
$check = Get-AzDnsZone
if ($check -ne $null)
{
Write-Output “It does not exisit”
Remove-AzDnsZone -Name wayne.com -ResourceGroupName powershelltest
Write-Output “It was removed”
break
}
else
{
New-AzDnsZone -Name wayne.com -ResourceGroupName powershelltest
Write-Output “It was created”
break
}

However, i am sure there is a better way to do with parameters at the very basic level. please help
param([string]$check)

Well your first line would not work since you did not specify a resource group (required). Your code is pretty static, if you want to make it more useful you’ll want to learn how to write a function.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.