Public/Set-IdracNIC.ps1
Function Set-IdracNIC{ [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='None')] Param ( [Parameter(Mandatory = $true)] [string]$iDRACName, [string]$DNSRacName = $null, [string]$DNSDomainName = $null, [bool]$DNSRegister = $null, [System.Management.Automation.PSCredential]$Credential ) begin{ $commandArray = @() if ($PSBoundParameters.ContainsKey('DNSRacName')){ $commandArray += "racadm set idrac.nic.DNSRacName $DNSRacName" } if ($PSBoundParameters.ContainsKey('DNSDomainName')){ $commandArray += "racadm set idrac.nic.DNSDomainName $DNSDomainName" } if ($PSBoundParameters.ContainsKey('DNSRegister')){ if($DNSRegister){ $commandArray += "racadm set idrac.nic.DNSRegister Enabled" } else{ $commandArray += "racadm set idrac.nic.DNSRegister Disabled" } } $session = New-iDRACSession -iDRACName $iDRACName -Credential $Credential } process{ foreach ($line in $commandArray){ if($PSCmdlet.ShouldProcess( "Verbose Description !", "Set Resource " + "Caption")){ $result = Invoke-SshCommand -Command $line -SSHSession $session $msg = $result.Host.ToUpper() + " - " + $result.Output Write-Verbose -Message $msg } } } End{ $session | Remove-SSHSession | Out-Null } } |