diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 653da69..1fc6be2 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -9,6 +9,7 @@ function Connect-ZertoServer { )] [ValidateNotNullOrEmpty()] [string]$zertoServer, + [Parameter( HelpMessage = "Zerto Virtual Manager management port. Default value is 9669." )] [string]$zertoPort = "9669", [Parameter( Mandatory = $true, @@ -18,11 +19,13 @@ function Connect-ZertoServer { $credential ) $zertoConnectionInformation = @{"zertoServer" = $zertoServer; "zertoPort" = $zertoPort; "LastAction" = $(get-date).Ticks} - Set-Item Env:zertoConnectionInformation -Value ($zertoConnectionInformation | convertto-json -Compress) + Set-Item Env:zertoConnectionInformation -Value ($zertoConnectionInformation | ConvertTo-Json -Compress) $body = '{"AuthenticationMethod": "1"}' $uri = "session/add" $results = Invoke-ZertoRestRequest -uri $uri -credential $credential -returnHeaders -body $body -method POST $zertoAuthorizationHeaders = @{"x-zerto-session" = $results.Headers['x-zerto-session'][0].ToString(); "Accept" = "application/json"} - Set-Item Env:zertoAuthorizationHeaders -Value ($zertoAuthorizationHeaders | convertto-json -Compress) + Set-Item Env:zertoAuthorizationHeaders -Value ($zertoAuthorizationHeaders | ConvertTo-Json -Compress) + $zertoLocalSiteInfo = Get-ZertoLocalSite + Set-Item Env:zertoLocalSiteInfo -Value ($zertoLocalSiteInfo | ConvertTo-Json -Compress) return $zertoAuthorizationHeaders } diff --git a/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 index f4ebc3c..807739f 100644 --- a/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 @@ -3,5 +3,6 @@ function Disconnect-ZertoServer { $uri = "session" Invoke-ZertoRestRequest -uri $uri -method DELETE Remove-Item Env:zertoAuthorizationHeaders - Remove-Item Env:zertoConnectionInformation + Remove-Item Env:zertoConnectionInformation + Remove-Item Env:zertoLocalSiteInfo } diff --git a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 index 7a5653f..152beff 100644 --- a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 @@ -41,7 +41,7 @@ function Get-ZertoProtectedVm { foreach ( $id in $vmIdentifier ) { $uri = "{0}/{1}" -f $baseUri, $id $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } diff --git a/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 b/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 index 71de0c6..f3f6b43 100644 --- a/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 @@ -24,7 +24,7 @@ function Get-ZertoServiceProfile { foreach ( $id in $serviceProfileId ) { $uri = "{0}/{1}" -f $baseUri, $id $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } diff --git a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 index ed4a549..8a15923 100644 --- a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 @@ -42,7 +42,7 @@ function Get-ZertoTask { foreach ( $id in $taskIdentifier ) { $uri = "{0}/{1}" -f $baseUri, $id $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } diff --git a/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 index 7ca40c9..fe45842 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 @@ -9,7 +9,7 @@ function Get-ZertoVirtualizationSite { [Parameter( ParameterSetName = "networks", Mandatory = $true )] [Parameter( ParameterSetName = "resourcePools", Mandatory = $true )] [Parameter( ParameterSetName = "vms", Mandatory = $true )] - [string[]]$siteIdentifiers, + # [string[]]$siteIdentifiers, [Parameter( ParameterSetName = "devices", Mandatory = $true )] [Parameter( ParameterSetName = "folders", Mandatory = $true )] [string]$siteIdentifier, @@ -50,40 +50,40 @@ function Get-ZertoVirtualizationSite { "devices" { foreach ( $id in $siteIdentifier ) { - if ( $PSBoundParameters.Contains( "hostIdentifier" ) ) { + if ( $PSBoundParameters.ContainsKey( "hostIdentifier" ) ) { $uri = "{0}/{1}/devices?hostIdentifier={2}" -f $baseUri, $siteIdentifier, $hostIdentifier } else { $uri = "{0}/{1}/devices" -f $baseUri, $siteIdentifier } $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } "hosts" { - if ( $PSBoundParameters.Contains( "hostIdentifier" ) ) { + if ( $PSBoundParameters.ContainsKey( "hostIdentifier" ) ) { $uri = "{0}/{1}/hosts/{2}" -f $baseUri, $siteIdentifier, $hostIdentifier } else { $uri = "{0}/{1}/hosts" -f $baseUri, $siteIdentifier } $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } "siteIdentifier" { - foreach ( $id in $siteIdentifiers ) { - $uri = "{0}/{1}" -f $baseUri, $id - $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) - } + # foreach ( $id in $siteIdentifier ) { + $uri = "{0}/{1}" -f $baseUri, $id + $results = Invoke-ZertoRestRequest -uri $uri + $returnObject.Add($results) | Out-Null + # } } default { - foreach ( $id in $siteIdentifiers ) { - $uri = "{0}/{1}/{2}" -f $baseUri, $siteIdentifier, $PSCmdlet.ParameterSetName.ToLower() - $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) - } + # foreach ( $id in $siteIdentifier ) { + $uri = "{0}/{1}/{2}" -f $baseUri, $siteIdentifier, $PSCmdlet.ParameterSetName.ToLower() + $results = Invoke-ZertoRestRequest -uri $uri + $returnObject.Add($results) | Out-Null + # } } } } diff --git a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 index 63d0ae1..7f1e03b 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 @@ -68,13 +68,13 @@ function Get-ZertoVpg { foreach ( $vpgId in $protectionGroupIdentifier ) { $uri = "{0}/{1}" -f $baseUri, $vpgId $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } "checkpoints" { $filter = $false - if ( $PSBoundParameters.Contains("startDate") -or $PSBoundParameters.Contains("endDate") ) { + if ( $PSBoundParameters.ContainsKey("startDate") -or $PSBoundParameters.ContainsKey("endDate") ) { $filter = $true $filterTable = @{} foreach ( $key in $PSBoundParameters.Keys ) { @@ -91,7 +91,7 @@ function Get-ZertoVpg { $uri = "{0}/{1}/checkpoints" -f $baseUri, $id } $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } @@ -99,7 +99,7 @@ function Get-ZertoVpg { foreach ( $id in $protectionGroupIdentifier ) { $uri = "{0}/{1}/checkpoints/stats" -f $baseUri, $id $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } @@ -107,13 +107,13 @@ function Get-ZertoVpg { $filter = Get-ZertoApiFilter -filterTable $PSBoundParameters $uri = "{0}{1}" -f $baseUri, $filter $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } default { $uri = "{0}/{1}" -f $baseUri, $PSCmdlet.ParameterSetName.ToLower() $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } } diff --git a/ZertoApiWrapper/Public/Get-ZertoVras.ps1 b/ZertoApiWrapper/Public/Get-ZertoVras.ps1 index 291cdc5..a4a69d4 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVras.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVras.ps1 @@ -29,7 +29,7 @@ function Get-ZertoVra { foreach ( $vraId in $vraIdentifier ) { $uri = "{0}/{1}" -f $baseUri, $vraId $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } else { $uri = $baseUri diff --git a/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 b/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 index 1b6c94b..41624c7 100644 --- a/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 @@ -13,12 +13,12 @@ function Get-ZertoZorg { process { if ( $PSCmdlet.ParameterSetName -eq "default" ) { $results = Invoke-ZertoRestRequest -uri $baseUri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } elseif ( $PSCmdlet.ParameterSetName -eq "zorgIdentifier" ) { foreach ( $id in $zorgIdentifier ) { $uri = "{0}/{1}" -f $baseUri, $id $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } } diff --git a/ZertoApiWrapper/Public/Get-ZsspSession.ps1 b/ZertoApiWrapper/Public/Get-ZsspSession.ps1 index d7e3bc1..78270d2 100644 --- a/ZertoApiWrapper/Public/Get-ZsspSession.ps1 +++ b/ZertoApiWrapper/Public/Get-ZsspSession.ps1 @@ -13,12 +13,12 @@ function Get-ZertoZsspSession { process { if ( $PSCmdlet.ParameterSetName -eq "default" ) { $results = Invoke-ZertoRestRequest -uri $baseUri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } elseif ( $PSCmdlet.ParameterSetName -eq "zsspSessionIdentifier" ) { foreach ( $id in $zsspSessionIdentifier ) { $uri = "{0}/{1}" -f $baseUri, $id $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) + $returnObject.Add($results) | Out-Null } } }