Public/Set-IdracNTP.ps1
Function Set-IdracNTP{ [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='None')] Param ( [Parameter(Mandatory = $true)] [string]$iDRACName, [Parameter(Mandatory = $true)] [string[]]$NTPServer, [System.Management.Automation.PSCredential]$Credential ) begin{ $commandArray = @() $i = 1 foreach ($item in $NTPServer){ $commandArray += "racadm set idrac.NTPConfigGroup.NTP$i $item" if ($i -ge 4){ #Valid range is 1 to 3 break } $i++ } $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 } } |