lib/Example.ps1
Function Get-ZertoItem { [CmdletBinding()] param( [Parameter(Mandatory = $false, HelpMessage = 'Zerto Session Name')][String]$ZertoSession = "Default" ) ## Get Session Configuration $ZertoSessionConfig = Get-ZertoSession -SessionName $ZertoSession #Honor SSL Settings if ($ZertoSessionConfig.AllowInsecureSSL) { $ZertoCertSettings = @{SkipCertificateCheck = $true } } else { $ZertoCertSettings = @{SkipCertificateCheck = $false } } $baseURL = "https://" + $ZertoSessionConfig.ZertoServer + ":" + $ZertoSessionConfig.ZertoPort + "/v1/" $TypeJSON = "application/json" $FullURL = $baseURL + "localsite" Write-Verbose $FullURL try { $RestMethodSplat = @{ Uri = $FullURL TimeoutSec = 100 ContentType = $TypeJSON Method = 'GET' WebSession = $ZertoSessionConfig.ZertoWebSession } $Result = Invoke-RestMethod @RestMethodSplat @ZertoCertSettings } catch { throw $_.Exception.Message } return $Result } |