public/Set-CTDNSSettings.ps1
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" } #Build Submission Object $obj = @{ IP = $IP Credential = $Credential DNSType = $DNSType PrimaryDNS = $PrimaryDNS SecondaryDNS = $SecondaryDNS } #Choose Camera Model Switch ($CameraType) { Hanwha { return Set-HanwhaDNSSettings -Object $obj } } } } |