public/Set-CTDNSSettings.ps1
#https://$($ip)/stw-cgi/network.cgi?msubmenu=dns&action=set&Type=Manual&PrimaryDNS=10.119.3.254&SecondaryDNS=10.119.3.254 Function Set-CTDNSSettings { [cmdletBinding( DefaultParameterSetName='All', #SupportsShouldProcess = $true, ConfirmImpact='high' )] Param( [Parameter( Mandatory=$true, ParameterSetName='All' )] [String]$IP, [Parameter( Mandatory=$true, ParameterSetName='All' )] [pscredential]$Credential, [Parameter( Mandatory=$false, ParameterSetName='All' )] [String]$PrimaryDNS, [Parameter( Mandatory=$false, ParameterSetName='All' )] [String]$SecondaryDNS ) DynamicParam { $DynamicParameters = @{ CameraType = @{ Mandatory = $true Position = 1 ParameterSetName = "All" Enum = $Script:SupportedCameraModels } DNSType = @{ Mandatory = $false Position = 2 ParameterSetName = 'All' Enum = @( 'Manual' 'DHCP' ) Value = 'Manual' } } return New-DynamicParameterSet -ParameterTable $DynamicParameters } Begin { Write-Debug "[Set-CTDNSSettings] Started" $CameraType = $PSBoundParameters.CameraType $DNSType = $PSBoundParameters.DNSType #Check Parameters if($DNSType -eq 'Manual' -and (!$PrimaryDNS -or !$SecondaryDNS)) { Throw "Manual DNS entry requires Primary and Secondary DNS" } if($CameraType -eq 'Hanwha') { #Set basic Paramters for Invoke-HanwhaCommand $CamCmd = @{ Arguments = @{ IP = $IP Menu = 'network' SubMenu = 'dns' Action = 'set' Parameters = @() } Credential = $Credential } #Add Action Parameters $CamCmd.Arguments.Parameters += "Type=$DNSType" if($DNSType -eq 'Manual') { $CamCmd.Arguments.Parameters += "PrimaryDNS=$PrimaryDNS" $CamCmd.Arguments.Parameters += "SecondaryDNS=$SecondaryDNS" } Invoke-HanwhaCommand @CamCmd } } } |