Skip to content

Commit

Permalink
Fix after review PowerAruba#2
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Moreau committed Feb 6, 2019
1 parent 17cb0f5 commit ce2ebab
Showing 1 changed file with 10 additions and 70 deletions.
80 changes: 10 additions & 70 deletions PowerArubaSW/Public/DNS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,14 @@ function Remove-ArubaSWDns {
Remove dns server or domain name
.EXAMPLE
Remove-ArubaSWDns -server1 none -server2 none -domain none
Remove-ArubaSWDns -mode Manual
This remove the ip of server 1 and server 2, and all the domain names
#>

Param(
[Parameter (Mandatory=$true)]
[ValidateSet ("DHCP", "Manual")]
[string]$mode,
[Parameter (Mandatory=$false)]
[string]$server1,
[Parameter (Mandatory=$false)]
[string]$server2,
[Parameter (Mandatory=$false)]
[array]$domain,
[Parameter(Mandatory = $false)]
[switch]$noconfirm
)
Expand All @@ -194,8 +188,6 @@ function Remove-ArubaSWDns {

$dns = new-Object -TypeName PSObject

$check = Get-ArubaSWDns

switch( $mode ) {
DHCP {
$mode_status = "DCM_DHCP"
Expand All @@ -205,71 +197,19 @@ function Remove-ArubaSWDns {
}
}

$dns | add-member -name "dns_config_mode" -membertype NoteProperty -Value $mode_status

if ( $PsBoundParameters.ContainsKey('server1') -and $PsBoundParameters.ContainsKey('server2') )
{
switch( $server1 ) {
none {
$dnsserver1 = $null
}
}

$dns | add-member -name "server_1" -membertype NoteProperty -Value $dnsserver1

switch( $server2 ) {
none {
$dnsserver2 = $null
}
}

$dns | add-member -name "server_2" -membertype NoteProperty -Value $dnsserver2

Write-Warning "Remove both of the ip address of dns servers will remove all the domain names"
}
else
{
if ($PsBoundParameters.ContainsKey('server1'))
{
switch( $server1 ) {
none {
$dnsserver1 = $null
}
}

$dns | add-member -name "server_1" -membertype NoteProperty -Value $dnsserver1
}
else
{
$dns | add-member -name "server_1" -membertype NoteProperty -Value $check.server_1
}
$dns | add-member -name "dns_config_mode" -membertype NoteProperty -Value $mode_status

$dnsserver1 = $null

if ($PsBoundParameters.ContainsKey('server2'))
{
switch( $server2 ) {
none {
$dnsserver2 = $null
}
}
$dns | add-member -name "server_1" -membertype NoteProperty -Value $dnsserver1

$dns | add-member -name "server_2" -membertype NoteProperty -Value $dnsserver2
}
else
{
$dns | add-member -name "server_2" -membertype NoteProperty -Value $check.server_2
}
}
$dnsserver2 = $null

if ( $PsBoundParameters.ContainsKey('domain') )
{
switch( $domain ) {
none {
$dnsdomain = $null
}
}
$dns | add-member -name "server_2" -membertype NoteProperty -Value $dnsserver2

$dnsdomain = $null

$dns | add-member -name "dns_domain_names" -membertype NoteProperty -Value $dnsdomain
}
$dns | add-member -name "dns_domain_names" -membertype NoteProperty -Value $dnsdomain

$url = "rest/v4/dns"

Expand Down

0 comments on commit ce2ebab

Please sign in to comment.