function Connect-ToVCenter { param( [string]$Server, [pscredential]$Credential ) ``` Import-Module VMware.PowerCLI -ErrorAction Stop Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null Invoke-Retry -Name "vCenter connect" -Action { Connect-VIServer -Server $Server -Credential $Credential -ErrorAction Stop | Out-Null } ``` }