diff --git a/PowerArubaCX/Public/System.ps1 b/PowerArubaCX/Public/System.ps1 index bdf0dfd..e0883d2 100644 --- a/PowerArubaCX/Public/System.ps1 +++ b/PowerArubaCX/Public/System.ps1 @@ -108,6 +108,12 @@ function Set-ArubaCXSystem { #add Check of timezone ? very long list.. [string]$timezone, [Parameter (Mandatory = $false)] + [string]$contact, + [Parameter (Mandatory = $false)] + [string]$description, + [Parameter (Mandatory = $false)] + [string]$location, + [Parameter (Mandatory = $false)] [switch]$use_pipeline, [Parameter (Mandatory = $False)] [ValidateNotNullOrEmpty()] @@ -138,6 +144,30 @@ function Set-ArubaCXSystem { if ( $PsBoundParameters.ContainsKey('timezone') ) { $_system.timezone = $timezone } + if ( $PsBoundParameters.ContainsKey('contact') ) { + if ($_system.other_config.system_contact) { + $_system.other_config.system_contact = $contact + } + else { + $_system.other_config | Add-member -name "system_contact" -membertype NoteProperty -Value $contact + } + } + if ( $PsBoundParameters.ContainsKey('description') ) { + if ($_system.other_config.system_description) { + $_system.other_config.system_description = $description + } + else { + $_system.other_config | Add-member -name "system_description" -membertype NoteProperty -Value $description + } + } + if ( $PsBoundParameters.ContainsKey('location') ) { + if ($_system.other_config.system_location) { + $_system.other_config.system_location = $location + } + else { + $_system.other_config | Add-member -name "system_location" -membertype NoteProperty -Value $location + } + } if ($PSCmdlet.ShouldProcess($_system.hostname, 'Configure System Settings')) { Invoke-ArubaCXRestMethod -method "PUT" -body $_system -uri $uri -connection $connection diff --git a/Tests/integration/System.Tests.ps1 b/Tests/integration/System.Tests.ps1 index 8975e5b..962182c 100644 --- a/Tests/integration/System.Tests.ps1 +++ b/Tests/integration/System.Tests.ps1 @@ -129,6 +129,41 @@ Describe "Configure System" { $sys.other_config.banner | Should -Be "PowerArubaCX-Banner" } + It "Change System contact (Add if needed)" { + Set-ArubaCXSystem -Contact "PowerArubaCX-Contact" + $sys = Get-ArubaCXSystem + $sys.other_config.system_contact | Should -Be "PowerArubaCX-Contact" + } + + It "Change System contact" { + Set-ArubaCXSystem -Contact "PowerArubaCX-Contact2" + $sys = Get-ArubaCXSystem + $sys.other_config.system_contact | Should -Be "PowerArubaCX-Contact2" + } + + It "Change System description (Add if needed)" { + Set-ArubaCXSystem -Description "PowerArubaCX-Description" + $sys = Get-ArubaCXSystem + $sys.other_config.system_description | Should -Be "PowerArubaCX-Description" + } + + It "Change System description" { + Set-ArubaCXSystem -description "PowerArubaCX-Description2" + $sys = Get-ArubaCXSystem + $sys.other_config.system_description | Should -Be "PowerArubaCX-Description2" + } + + It "Change System location (Add if needed)" { + Set-ArubaCXSystem -location "PowerArubaCX-Location" + $sys = Get-ArubaCXSystem + $sys.other_config.system_location | Should -Be "PowerArubaCX-Location" + } + + It "Change System location" { + Set-ArubaCXSystem -location "PowerArubaCX-Location2" + $sys = Get-ArubaCXSystem + $sys.other_config.system_location | Should -Be "PowerArubaCX-Location2" + } AfterAll { $default_sys | Set-ArubaCXSystem -use_pipeline #Reverse CheckPoint ?