From cdad0c5e795a0a697a0889bb895327b48033ec38 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Jun 2020 09:43:48 -0400 Subject: [PATCH 01/38] Correct example numbering issue --- docs/Get-ZertoEvent.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Get-ZertoEvent.md b/docs/Get-ZertoEvent.md index d9e842e..50d9273 100644 --- a/docs/Get-ZertoEvent.md +++ b/docs/Get-ZertoEvent.md @@ -66,7 +66,7 @@ PS C:\> Get-ZertoEvent -eventId "Need an eventID" Returns information for each -eventID specified. -### Example 1 +### Example 3 ```powershell PS C:\> Get-ZertoEvent -startDate "2019-01-01" -endDate "2019-01-07" -vpg "My Vpg" ``` From 1e84f5aea0a7b28045776dad8d64483d94aee0ae Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 9 Jun 2020 15:21:11 -0400 Subject: [PATCH 02/38] Add Username Example added example with username filter --- docs/Get-ZertoEvent.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/Get-ZertoEvent.md b/docs/Get-ZertoEvent.md index 50d9273..cf6683b 100644 --- a/docs/Get-ZertoEvent.md +++ b/docs/Get-ZertoEvent.md @@ -73,6 +73,13 @@ PS C:\> Get-ZertoEvent -startDate "2019-01-01" -endDate "2019-01-07" -vpg "My Vp Returns all events between Jan. 01, 2019 and Jan. 07, 2019 (inclusive) for the vpg "My Vpg" +### Example 4 +```powershell +PS C:\> Get-ZertoEvent -userName "Domain.tld\MyUser +``` + +Returns all events associated with the username passed into the command. + ## PARAMETERS ### -alertIdentifier From 73540faeb90e1461f3e4d489b1e415f2bbf890f0 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 9 Jun 2020 22:33:48 -0400 Subject: [PATCH 03/38] Update Build Paths --- ZertoApiWrapper.build.ps1 | 60 +++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 853d110..cc0b33f 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,23 +1,24 @@ #Requires -Modules 'InvokeBuild' $version = "{0}" -f $(Get-Content .\version.txt) +$moduleOutPath = "{0}\temp\{1}\ZertoApiWrapper" -f $BuildRoot, $version #Define the default task task . CreateArtifacts #Region - Helper Functions -function ImportSourceModule() { +function ImportSourceModule { If (Get-Module -Name ZertoApiWrapper) { Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop } Import-Module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -ErrorAction Stop } -function ImportBuiltModule() { +function ImportBuiltModule { If (Get-Module -Name ZertoApiWrapper) { Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop } - Import-Module "$BuildRoot\temp\ZertoApiWrapper.psd1" -ErrorAction Stop + Import-Module ("{0}\ZertoApiWrapper.psd1" -f $moduleOutPath) -ErrorAction Stop } #EndRegion @@ -65,7 +66,7 @@ task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { $scriptAnalyzerParams = @{ - Path = "$BuildRoot\temp\" + Path = $moduleOutPath Severity = @('Error', 'Warning') Recurse = $true Verbose = $false @@ -82,10 +83,10 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { #Region - Clean Operations task CleanTemp { - if (-not $(Test-Path "$BuildRoot\temp")) { - New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory" + if (-not $(Test-Path $moduleOutPath)) { + New-Item -Path $moduleOutPath -ItemType "Directory" } - Remove-Item -Recurse -Path "$BuildRoot\temp\*" + Remove-Item -Recurse -Path ("{0}\*" -f $moduleOutPath) } task CleanPublish { @@ -116,7 +117,7 @@ task BuiltFileTests CreatePsm1ForRelease, CheckPesterInstalled, { #Region - Build Help System $buildMamlParams = @{ Inputs = { Get-ChildItem docs\*.md } - Outputs = "$BuildRoot\temp\en-us\ZertoApiWrapper-help.xml" + Outputs = "{0}\en-us\ZertoApiWrapper-help.xml" -f $moduleOutPath } task BuildMamlHelp CheckPlatyPSInstalled, { @@ -126,8 +127,8 @@ task BuildMamlHelp CheckPlatyPSInstalled, { platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs } -task UpdateMarkdownHelp CheckPlatyPSInstalled, { - ImportSourceModule +task UpdateMarkdownHelp quickBuild, CheckPlatyPSInstalled, { + ImportBuiltModule Update-MarkdownHelpModule -Path docs -AlphabeticParamsOrder } #EndRegion @@ -138,7 +139,7 @@ task CreatePsd1ForRelease CleanTemp, { $releaseNotes = "Please review the [Release Notes](https://github.com/ZertoPublic/ZertoApiWrapper/releases/tag/{0}) on GitHub." -f $version $ManifestParams = @{ - Path = "$BuildRoot\temp\ZertoApiWrapper.psd1" + Path = "{0}\ZertoApiWrapper.psd1" -f $moduleOutPath RootModule = 'ZertoApiWrapper.psm1' ModuleVersion = $version GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325' @@ -161,25 +162,25 @@ task CreatePsd1ForRelease CleanTemp, { task CreatePsm1ForRelease CreatePsd1ForRelease, { $emptyLine = "" - $psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1" + $psm1Path = "{0}\ZertoApiWrapper.psm1" -f $moduleOutPath $lines = '#------------------------------------------------------------#' $Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction Stop ) $Public = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction Stop ) - Add-Content -Path $psm1Path -Value $lines - Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#" - Add-Content -Path $psm1Path -Value $lines - Add-Content -Path $psm1Path -Value $emptyLine + Add-Content -Path $psm1Path -Value $lines -Encoding 'utf8' + Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#" -Encoding 'utf8' + Add-Content -Path $psm1Path -Value $lines -Encoding 'utf8' + Add-Content -Path $psm1Path -Value $emptyLine -Encoding 'utf8' foreach ($file in $private) { - Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) - Add-Content -Path $psm1Path -Value $emptyLine + Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) -Encoding 'utf8' + Add-Content -Path $psm1Path -Value $emptyLine -Encoding 'utf8' } - Add-Content -Path $psm1Path -Value $lines - Add-Content -Path $psm1Path -Value "#----------------------Public Functions----------------------#" - Add-Content -Path $psm1Path -Value $lines - Add-Content -Path $psm1Path -Value $emptyLine + Add-Content -Path $psm1Path -Value $lines -Encoding 'utf8' + Add-Content -Path $psm1Path -Value "#----------------------Public Functions----------------------#" -Encoding 'utf8' + Add-Content -Path $psm1Path -Value $lines -Encoding 'utf8' + Add-Content -Path $psm1Path -Value $emptyLine -Encoding 'utf8' foreach ($file in $public) { - Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) - Add-Content -Path $psm1Path -Value $emptyLine + Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) -Encoding 'utf8' + Add-Content -Path $psm1Path -Value $emptyLine -Encoding 'utf8' } # Add-Content -Path $psm1Path -Value $emptyLine # Add-Content -Path $psm1Path -Value "Export-ModuleMember -Function $exportString" @@ -188,7 +189,7 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, { #Region - Artifacts \ Publish # Full Build Process - No Publishing -task CreateArtifacts CleanPublish, CleanTemp, AnalyzeSourceFiles, SourceFileTests, AnalyzeBuiltFiles, BuiltFileTests, BuildMamlHelp, { +task CreateArtifacts CleanPublish, CleanTemp, AnalyzeBuiltFiles, BuiltFileTests, BuildMamlHelp, { if (-not $(Test-Path "$BuildRoot\publish")) { New-Item -Path $BuildRoot -Name "publish" -ItemType Directory } @@ -201,3 +202,12 @@ task CreateArtifacts CleanPublish, CleanTemp, AnalyzeSourceFiles, SourceFileTest Copy-Item "$BuildRoot\build.ps1" "$BuildRoot\publish\build.ps1" } #EndRegion + +task build CleanPublish, CleanTemp, CreatePsm1ForRelease, AnalyzeBuiltFiles, BuiltFileTests, CreateArtifacts +task quickBuild CleanPublish, CleanTemp, CreatePsm1ForRelease, AnalyzeBuiltFiles, { + Get-Module -Name ZertoApiWrapper | Remove-Module -Force + ImportBuiltModule +} +task release quickBuild, { + Publish-Module -Path $moduleOutPath -NuGetApiKey "1234" -WhatIf +} From 32403ec3e3abe29204327d9d8cf5068df5394c72 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 09:41:37 -0400 Subject: [PATCH 04/38] Update build script with params --- build.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 9ce90cf..2f2c873 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,3 +1,5 @@ +param([validateSet("build", "release")]$operation = "build") + # Bootstrap the environment $null = Get-PackageProvider -Name NuGet -ForceBootstrap @@ -11,6 +13,7 @@ Invoke-PSDepend ` -Force ` -Import ` -Install ` - -Tags 'Bootstrap' + -Tags 'Bootstrap' ` + -ErrorAction Continue -Invoke-Build . +Invoke-Build $operation From 925ecaf2247a049e85f52bf514be486c0ed9de1c Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 09:42:17 -0400 Subject: [PATCH 05/38] Update default build operation --- ZertoApiWrapper.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index cc0b33f..9e2d883 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -4,7 +4,7 @@ $version = "{0}" -f $(Get-Content .\version.txt) $moduleOutPath = "{0}\temp\{1}\ZertoApiWrapper" -f $BuildRoot, $version #Define the default task -task . CreateArtifacts +task . build #Region - Helper Functions function ImportSourceModule { From e90d2a23cc52f6ccdd0e978c5c91697aaeb2f9d7 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 09:42:41 -0400 Subject: [PATCH 06/38] Update tests to only show failed --- ZertoApiWrapper.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 9e2d883..788ed57 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -108,7 +108,7 @@ task SourceFileTests CheckPesterInstalled, { task BuiltFileTests CreatePsm1ForRelease, CheckPesterInstalled, { ImportBuiltModule $testResultsFile = "$BuildRoot\Tests\BuiltTestResults.xml" - $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails + $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Failed $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount Assert ($results.FailedCount -eq 0) $FailureMessage } From c7c3428dd5cb0b48ccbe70e045d48e9cd465aa20 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 09:43:03 -0400 Subject: [PATCH 07/38] Update release task to use full build process --- ZertoApiWrapper.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 788ed57..8069b4c 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -208,6 +208,6 @@ task quickBuild CleanPublish, CleanTemp, CreatePsm1ForRelease, AnalyzeBuiltFiles Get-Module -Name ZertoApiWrapper | Remove-Module -Force ImportBuiltModule } -task release quickBuild, { +task release build, { Publish-Module -Path $moduleOutPath -NuGetApiKey "1234" -WhatIf } From 906d35186fd6569920bc1d7dd560f953305ae995 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 09:43:32 -0400 Subject: [PATCH 08/38] Update Required Module Versions --- ZertoApiWrapper.Depend.psd1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 index 820e1f4..e3f8356 100644 --- a/ZertoApiWrapper.Depend.psd1 +++ b/ZertoApiWrapper.Depend.psd1 @@ -7,7 +7,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '5.5.11' + Version = '5.6.0' Tags = 'Bootstrap' } @@ -31,7 +31,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '1.18.3' + Version = '1.19.0' Tags = 'Bootstrap' } From aab22cf266e576168e60ccaea1ab155962061c29 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 09:53:01 -0400 Subject: [PATCH 09/38] Add Branch to Auto-Build --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e5c7180..6cb32e3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,6 +11,7 @@ trigger: include: - master - PowerShellBackPort + - Refactor-Build # Trigger CI on pull requests to master and develop branches pr: From a55b0cd46734e4f220a7ec62bd0ac9abe9f27221 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 09:58:32 -0400 Subject: [PATCH 10/38] Remove SourceFileTests publish --- azure-pipelines.yml | 149 ++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 89 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6cb32e3..3a21d03 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,26 +25,18 @@ jobs: pool: vmImage: windows-latest steps: - # Run build.ps1 script in PowerShell Core - - powershell: | - .\build.ps1 -Verbose - displayName: 'Build and Test' - # Upload test results to Azure Pipeline - - task: PublishTestResults@2 - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/SourceTestResults.xml' - testRunTitle: 'PS_Win2016_Source' - displayName: 'Publish Test Results' - condition: always() - - task: PublishTestResults@2 - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/BuiltTestResults.xml' - testRunTitle: 'PS_Win2016_Built' - displayName: 'Publish Test Results' - condition: always() - + # Run build.ps1 script in PowerShell Core + - powershell: | + .\build.ps1 -Verbose + displayName: "Build and Test" + # Upload test results to Azure Pipeline + - task: PublishTestResults@2 + inputs: + testRunner: "NUnit" + testResultsFiles: "**/BuiltTestResults.xml" + testRunTitle: "PS_Win2016_Built" + displayName: "Publish Test Results" + condition: always() # Windows PowerShell Core Build Job - job: Build_PSCore_Windows @@ -53,25 +45,18 @@ jobs: pool: vmImage: windows-latest steps: - # Run build.ps1 script in PowerShell Core - - pwsh: | - .\build.ps1 -Verbose - displayName: 'Build and Test' - # Upload test results to Azure Pipeline - - task: PublishTestResults@2 - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/SourceTestResults.xml' - testRunTitle: 'PSCore_Win2016_Source' - displayName: 'Publish Test Results' - condition: always() - - task: PublishTestResults@2 - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/BuiltTestResults.xml' - testRunTitle: 'PSCore_Win2016_Built' - displayName: 'Publish Test Results' - condition: always() + # Run build.ps1 script in PowerShell Core + - pwsh: | + .\build.ps1 -Verbose + displayName: "Build and Test" + # Upload test results to Azure Pipeline + - task: PublishTestResults@2 + inputs: + testRunner: "NUnit" + testResultsFiles: "**/BuiltTestResults.xml" + testRunTitle: "PSCore_Win2016_Built" + displayName: "Publish Test Results" + condition: always() # Linux Build Job - job: Build_PSCore_Ubuntu @@ -80,37 +65,30 @@ jobs: pool: vmImage: ubuntu-latest steps: - # Run build.ps1 script in PowerShell Core - - pwsh: | - .\build.ps1 -verbose - displayName: 'Build and Test' - # Upload test results to Azure Pipeline - - task: PublishTestResults@2 - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/SourceTestResults.xml' - testRunTitle: 'PSCore_Ubuntu_Source' - displayName: 'Publish Test Results' - condition: always() - - task: PublishTestResults@2 - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/BuiltTestResults.xml' - testRunTitle: 'PSCore_Ubuntu_Built' - displayName: 'Publish Test Results' - condition: always() - - task: PublishPipelineArtifact@0 - displayName: 'Publish compiled module Artifact' - inputs: - artifactName: 'ZertoApiWrapper' - targetPath: ./temp - condition: always() - - task: PublishPipelineArtifact@0 - displayName: 'Publish Data' - inputs: - artifactName: 'ReleaseData' - targetPath: ./publish - condition: always() + # Run build.ps1 script in PowerShell Core + - pwsh: | + .\build.ps1 -verbose + displayName: "Build and Test" + # Upload test results to Azure Pipeline + - task: PublishTestResults@2 + inputs: + testRunner: "NUnit" + testResultsFiles: "**/BuiltTestResults.xml" + testRunTitle: "PSCore_Ubuntu_Built" + displayName: "Publish Test Results" + condition: always() + - task: PublishPipelineArtifact@0 + displayName: "Publish compiled module Artifact" + inputs: + artifactName: "ZertoApiWrapper" + targetPath: ./temp + condition: always() + - task: PublishPipelineArtifact@0 + displayName: "Publish Data" + inputs: + artifactName: "ReleaseData" + targetPath: ./publish + condition: always() # MacOS Build Job - job: Build_PSCore_MacOS @@ -119,22 +97,15 @@ jobs: pool: vmImage: macOS-latest steps: - # Run build.ps1 script in PowerShell Core - - pwsh: | - .\build.ps1 -verbose - displayName: 'Build and Test' - # Upload test results to Azure Pipeline - - task: PublishTestResults@2 - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/SourceTestResults.xml' - testRunTitle: 'PSCore_MacOS1013_Source' - displayName: 'Publish Test Results' - condition: always() - - task: PublishTestResults@2 - inputs: - testRunner: 'NUnit' - testResultsFiles: '**/BuiltTestResults.xml' - testRunTitle: 'PSCore_MacOS1013_Built' - displayName: 'Publish Test Results' - condition: always() + # Run build.ps1 script in PowerShell Core + - pwsh: | + .\build.ps1 -verbose + displayName: "Build and Test" + # Upload test results to Azure Pipeline + - task: PublishTestResults@2 + inputs: + testRunner: "NUnit" + testResultsFiles: "**/BuiltTestResults.xml" + testRunTitle: "PSCore_MacOS1013_Built" + displayName: "Publish Test Results" + condition: always() From 9ad9cb7f1e4624ec98b6efeded65f032a8820875 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 12:20:00 -0400 Subject: [PATCH 11/38] Update Build Path for Artifact Utilization --- ZertoApiWrapper.build.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 8069b4c..f41483f 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,7 +1,7 @@ #Requires -Modules 'InvokeBuild' $version = "{0}" -f $(Get-Content .\version.txt) -$moduleOutPath = "{0}\temp\{1}\ZertoApiWrapper" -f $BuildRoot, $version +$moduleOutPath = "{0}\temp\ZertoApiWrapper\{1}" -f $BuildRoot, $version #Define the default task task . build @@ -193,7 +193,8 @@ task CreateArtifacts CleanPublish, CleanTemp, AnalyzeBuiltFiles, BuiltFileTests, if (-not $(Test-Path "$BuildRoot\publish")) { New-Item -Path $BuildRoot -Name "publish" -ItemType Directory } - Compress-Archive -Path .\temp\* -DestinationPath .\publish\ZertoApiWrapper.zip + $CompressionPath = Split-Path -Path $moduleOutPath -Parent + Compress-Archive -Path $CompressionPath -DestinationPath .\publish\ZertoApiWrapper.zip #ImportBuiltModule #(Get-Module ZertoApiWrapper).ReleaseNotes | Add-Content .\publish\release-notes.txt #(Get-Module ZertoApiWrapper).Version.ToString() | Add-Content .\publish\release-version.txt From 512d5bbd749bb7fcf1ff623f79c6d87f4d8b87ee Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 15:52:59 -0400 Subject: [PATCH 12/38] Update Publish Location --- ZertoApiWrapper.build.ps1 | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index f41483f..593e376 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,7 +1,7 @@ #Requires -Modules 'InvokeBuild' $version = "{0}" -f $(Get-Content .\version.txt) -$moduleOutPath = "{0}\temp\ZertoApiWrapper\{1}" -f $BuildRoot, $version +$moduleOutPath = "{0}\publish\ZertoApiWrapper" -f $BuildRoot #Define the default task task . build @@ -82,17 +82,13 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { #EndRegion #Region - Clean Operations -task CleanTemp { - if (-not $(Test-Path $moduleOutPath)) { - New-Item -Path $moduleOutPath -ItemType "Directory" - } - Remove-Item -Recurse -Path ("{0}\*" -f $moduleOutPath) -} - task CleanPublish { if ($(Test-Path "$BuildRoot\publish")) { Remove-Item -Recurse -Path "$BuildRoot\publish\*" + } else { + New-Item -Path $BuildRoot -Name "publish" -ItemType Directory } + New-Item -Path $moduleOutPath -ItemType "Directory" } #EndRegion @@ -134,7 +130,7 @@ task UpdateMarkdownHelp quickBuild, CheckPlatyPSInstalled, { #EndRegion #Region - Build Module Files -task CreatePsd1ForRelease CleanTemp, { +task CreatePsd1ForRelease CleanPublish, { $functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName } $releaseNotes = "Please review the [Release Notes](https://github.com/ZertoPublic/ZertoApiWrapper/releases/tag/{0}) on GitHub." -f $version @@ -182,30 +178,18 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, { Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) -Encoding 'utf8' Add-Content -Path $psm1Path -Value $emptyLine -Encoding 'utf8' } - # Add-Content -Path $psm1Path -Value $emptyLine - # Add-Content -Path $psm1Path -Value "Export-ModuleMember -Function $exportString" } #EndRegion #Region - Artifacts \ Publish # Full Build Process - No Publishing -task CreateArtifacts CleanPublish, CleanTemp, AnalyzeBuiltFiles, BuiltFileTests, BuildMamlHelp, { - if (-not $(Test-Path "$BuildRoot\publish")) { - New-Item -Path $BuildRoot -Name "publish" -ItemType Directory - } - $CompressionPath = Split-Path -Path $moduleOutPath -Parent - Compress-Archive -Path $CompressionPath -DestinationPath .\publish\ZertoApiWrapper.zip - #ImportBuiltModule - #(Get-Module ZertoApiWrapper).ReleaseNotes | Add-Content .\publish\release-notes.txt - #(Get-Module ZertoApiWrapper).Version.ToString() | Add-Content .\publish\release-version.txt - Copy-Item "$BuildRoot\ZertoApiWrapper.build.ps1" "$BuildRoot\publish\ZertoApiWrapper.build.ps1" - Copy-Item "$BuildRoot\ZertoApiWrapper.Depend.psd1" "$BuildRoot\publish\ZertoApiWrapper.Depend.psd1" - Copy-Item "$BuildRoot\build.ps1" "$BuildRoot\publish\build.ps1" +task CreateArtifacts CleanPublish, AnalyzeBuiltFiles, BuiltFileTests, BuildMamlHelp, { + Compress-Archive -Path $moduleOutPath -DestinationPath .\publish\ZertoApiWrapper.zip } #EndRegion -task build CleanPublish, CleanTemp, CreatePsm1ForRelease, AnalyzeBuiltFiles, BuiltFileTests, CreateArtifacts -task quickBuild CleanPublish, CleanTemp, CreatePsm1ForRelease, AnalyzeBuiltFiles, { +task build CleanPublish, CreatePsm1ForRelease, AnalyzeBuiltFiles, BuiltFileTests, CreateArtifacts +task quickBuild CleanPublish, CreatePsm1ForRelease, AnalyzeBuiltFiles, { Get-Module -Name ZertoApiWrapper | Remove-Module -Force ImportBuiltModule } From d3acba3967fd0476ddcbf7e4853beae709a25ee5 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 15:54:59 -0400 Subject: [PATCH 13/38] Remove Unused Publish Task --- azure-pipelines.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3a21d03..ceb0914 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -77,12 +77,6 @@ jobs: testRunTitle: "PSCore_Ubuntu_Built" displayName: "Publish Test Results" condition: always() - - task: PublishPipelineArtifact@0 - displayName: "Publish compiled module Artifact" - inputs: - artifactName: "ZertoApiWrapper" - targetPath: ./temp - condition: always() - task: PublishPipelineArtifact@0 displayName: "Publish Data" inputs: From de1a85cecd63777da453350df3a86e5de7eba6e6 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 10 Jun 2020 19:30:50 -0400 Subject: [PATCH 14/38] Add ReleaseNotes.md File Creation --- ZertoApiWrapper.build.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 593e376..08efbac 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -185,6 +185,12 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, { # Full Build Process - No Publishing task CreateArtifacts CleanPublish, AnalyzeBuiltFiles, BuiltFileTests, BuildMamlHelp, { Compress-Archive -Path $moduleOutPath -DestinationPath .\publish\ZertoApiWrapper.zip + $MyMatches = Select-String -Path "$BuildRoot\CHANGELOG.md" "^##\s\[" + $data = Get-Content "$BuildRoot\CHANGELOG.md" + $range = ($MyMatches[0].LineNumber - 1)..($MyMatches[1].LineNumber - 3) + foreach ($i in $range) { + Add-Content -Path "$BuildRoot\publish\ReleaseNotes.md" -Value ($data[$i]).replace("## ", "# ") -Encoding utf8 + } } #EndRegion From f81a22ca80ab094094f0dfef0682b1aaeb477e94 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 11 Jun 2020 09:24:02 -0400 Subject: [PATCH 15/38] Update Artifact Publish task to latest --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ceb0914..b20a9a2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -77,7 +77,7 @@ jobs: testRunTitle: "PSCore_Ubuntu_Built" displayName: "Publish Test Results" condition: always() - - task: PublishPipelineArtifact@0 + - task: PublishPipelineArtifact@1 displayName: "Publish Data" inputs: artifactName: "ReleaseData" From e021a7bab0f745dc6af0c2e86758618e23bfb902 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 18 Jun 2020 13:20:10 -0400 Subject: [PATCH 16/38] Added Time Example Struggled to find a time example. Added one for future use. --- docs/Get-ZertoEvent.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/Get-ZertoEvent.md b/docs/Get-ZertoEvent.md index cf6683b..25532cb 100644 --- a/docs/Get-ZertoEvent.md +++ b/docs/Get-ZertoEvent.md @@ -80,6 +80,13 @@ PS C:\> Get-ZertoEvent -userName "Domain.tld\MyUser Returns all events associated with the username passed into the command. +### Example 5 +```powershell +PS C:\> Get-ZertoEvent -startDate "2019-01-01T12:30:00" -endDate "2019-01-01T13:30:00" -vpg "My Vpg" +``` + +Returns all events between Jan. 01, 2019 12:30 PM and Jan. 01, 2019 1:30 PM (inclusive) for the vpg "My Vpg" + ## PARAMETERS ### -alertIdentifier From 3000a2b0139dd8d08cf48e07606ebba259f44404 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 8 Jun 2020 12:50:29 -0400 Subject: [PATCH 17/38] Initial auto reconnect --- .../Public/Connect-ZertoServer.ps1 | 10 +- .../Public/Invoke-ZertoRestRequest.ps1 | 100 +++++++++--------- 2 files changed, 60 insertions(+), 50 deletions(-) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index f9f33ac..9a8c649 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -22,7 +22,11 @@ function Connect-ZertoServer { HelpMessage = "Valid credentials to connect to the Zerto Management Server" )] [System.Management.Automation.PSCredential]$credential, - [switch]$returnHeaders + [switch]$returnHeaders, + [Parameter( + HelpMessage = "Use this switch to indicate that you would like the module to take care of auto re-authorization and reconnection to the ZVM should the token expire. This option will cache your PSCredential object to be reused" + )] + [switch]$AutoReconnect ) begin { @@ -38,6 +42,10 @@ function Connect-ZertoServer { "Accept" = "application/json" "zerto-triggered-by" = "PowershellWes" } + Set-Variable -Name Reconnect -Scope Script -Value $AutoReconnect.IsPresent + if ($Script:Reconnect) { + Set-Variable -Name CachedCredential -Scope Script -Value $credential + } } process { diff --git a/ZertoApiWrapper/Public/Invoke-ZertoRestRequest.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoRestRequest.ps1 index 97430ab..93d77e4 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoRestRequest.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoRestRequest.ps1 @@ -41,24 +41,26 @@ function Invoke-ZertoRestRequest { } # If the Headers exist and the Last action was more than 30 minutes ago, Session is Expired - if ( (Test-Path variable:script:zvmHeaders) -and $([datetime]$script:zvmLastAction).addMinutes(30) -lt $(Get-Date) ) { + if ( (Test-Path variable:script:zvmHeaders) -and $([datetime]$script:zvmLastAction).addMinutes(30) -lt $(Get-Date) -and $Script:Reconnect -eq $False ) { Throw "Authorization Token has Expired. Please re-authorize to the Zerto Virtual Manager" - } else { - - # Build the URI to be submitted - $submittedURI = "https://{0}:{1}/{2}/{3}" -f $script:zvmServer, $script:zvmPort, $apiVersion, $uri - try { - # Set the zvmLastAction time and try to submit the REST Request - $script:zvmLastAction = (Get-Date).Ticks - # If running PwSh - Use this Invoke-RestMethod with passed Variables - if ($PSVersionTable.PSVersion.Major -ge 6) { - $apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -SkipCertificateCheck -ResponseHeadersVariable responseHeaders -TimeoutSec 100 - } else { - # If running PowerShell 5.1 --> Do the Following - # Check to see if All Certs are Trusted. If not, Create the Policy to Trust All Certificates - if ([System.Net.ServicePointManager]::CertificatePolicy.GetType().Name -ne "TrustAllCertsPolicy") { - Try { - $type = @' + } elseif (( (Test-Path variable:script:zvmHeaders) -and $([datetime]$script:zvmLastAction).addMinutes(30) -lt $(Get-Date) -and $Script:Reconnect -eq $True )) { + Write-Verbose "Authorization had expired. Attempting Reauthorization." + Connect-ZertoServer -zertoServer $Script:zvmServer -zertoPort $script:zvmPort -credential $Script:CachedCredential + }# else { + # Build the URI to be submitted + $submittedURI = "https://{0}:{1}/{2}/{3}" -f $script:zvmServer, $script:zvmPort, $apiVersion, $uri + try { + # Set the zvmLastAction time and try to submit the REST Request + $script:zvmLastAction = (Get-Date).Ticks + # If running PwSh - Use this Invoke-RestMethod with passed Variables + if ($PSVersionTable.PSVersion.Major -ge 6) { + $apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -SkipCertificateCheck -ResponseHeadersVariable responseHeaders -TimeoutSec 100 + } else { + # If running PowerShell 5.1 --> Do the Following + # Check to see if All Certs are Trusted. If not, Create the Policy to Trust All Certificates + if ([System.Net.ServicePointManager]::CertificatePolicy.GetType().Name -ne "TrustAllCertsPolicy") { + Try { + $type = @' using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { @@ -67,42 +69,42 @@ public class TrustAllCertsPolicy : ICertificatePolicy { } } '@ - Add-Type -TypeDefinition $type -ErrorAction SilentlyContinue - } Catch { - if ($error[0].Exception -ne "Cannot add type. The type name 'TrustAllCertsPolicy already exists.") { - Write-Debug $error[0] - } + Add-Type -TypeDefinition $type -ErrorAction SilentlyContinue + } Catch { + if ($error[0].Exception -ne "Cannot add type. The type name 'TrustAllCertsPolicy already exists.") { + Write-Debug $error[0] } - [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy + } + [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy - } - # If we are authenticating to the ZVM, Use this block to use Invoke-WebRequest and format the Headers as expected. - if ($uri -eq "session/add" -and $method -eq "POST") { - $apiRequestResults = Invoke-WebRequest -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -TimeoutSec 100 - $responseHeaders = @{ } - $responseHeaders['x-zerto-session'] = @($apiRequestResults.Headers['x-zerto-session']) - } elseif ($method -ne "GET") { - # If the Method is something other than 'GET' use this call with a body parameter - $apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -TimeoutSec 100 - } else { - # If the Method we are calling is 'GET' use this call without a body parameter - $apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -ContentType $contentType -Credential $credential -TimeoutSec 100 - } } - } catch { - # If an error is encountered, Catch - Write-Error -ErrorRecord $_ -ErrorAction $callerErrorActionPreference + # If we are authenticating to the ZVM, Use this block to use Invoke-WebRequest and format the Headers as expected. + if ($uri -eq "session/add" -and $method -eq "POST") { + $apiRequestResults = Invoke-WebRequest -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -TimeoutSec 100 + $responseHeaders = @{ } + $responseHeaders['x-zerto-session'] = @($apiRequestResults.Headers['x-zerto-session']) + } elseif ($method -ne "GET") { + # If the Method is something other than 'GET' use this call with a body parameter + $apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -TimeoutSec 100 + } else { + # If the Method we are calling is 'GET' use this call without a body parameter + $apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -ContentType $contentType -Credential $credential -TimeoutSec 100 + } } + } catch { + # If an error is encountered, Catch + Write-Error -ErrorRecord $_ -ErrorAction $callerErrorActionPreference + } - # If the calling function does not need the headers (Default Action) return the results of the API Call - if (-not $returnHeaders) { - return $apiRequestResults - } else { - #If Headers are required, build a PS Custom Object with the Results and the Headers - $apiRequestAndHeaderResults = New-Object -TypeName psobject - $apiRequestAndHeaderResults | Add-Member -MemberType NoteProperty -Name "apiRequestResults" -Value $apiRequestResults - $apiRequestAndHeaderResults | Add-Member -MemberType NoteProperty -Name "Headers" -Value $responseHeaders - return $apiRequestAndHeaderResults - } + # If the calling function does not need the headers (Default Action) return the results of the API Call + if (-not $returnHeaders) { + return $apiRequestResults + } else { + #If Headers are required, build a PS Custom Object with the Results and the Headers + $apiRequestAndHeaderResults = New-Object -TypeName psobject + $apiRequestAndHeaderResults | Add-Member -MemberType NoteProperty -Name "apiRequestResults" -Value $apiRequestResults + $apiRequestAndHeaderResults | Add-Member -MemberType NoteProperty -Name "Headers" -Value $responseHeaders + return $apiRequestAndHeaderResults + #} } } From 348fcbd28c7d8e16be8ada599e54652bcc1c8949 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 11 Jun 2020 14:19:20 -0400 Subject: [PATCH 18/38] Update Help for AutoReconnect switch --- docs/Connect-ZertoServer.md | 247 ++++++++++++++++++++---------------- 1 file changed, 135 insertions(+), 112 deletions(-) diff --git a/docs/Connect-ZertoServer.md b/docs/Connect-ZertoServer.md index 160ac31..ad36a82 100644 --- a/docs/Connect-ZertoServer.md +++ b/docs/Connect-ZertoServer.md @@ -1,112 +1,135 @@ ---- -external help file: ZertoApiWrapper-help.xml -Module Name: ZertoApiWrapper -online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Connect-ZertoServer.md -schema: 2.0.0 ---- - -# Connect-ZertoServer - -## SYNOPSIS -Establishes a connection to a ZVM. - -## SYNTAX - -``` -Connect-ZertoServer [-zertoServer] [[-zertoPort] ] [-credential] - [-returnHeaders] [] -``` - -## DESCRIPTION -Establishes a connection to a ZVM using credentials provided via a PSCredential Object leveraging the Zerto Session API end point. - -## EXAMPLES - -### Example 1 -```powershell -PS C:\> Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "9669" -credential $credential -``` - -Establishes a connection to ZVM 192.168.1.100 on port 9669 with supplied PSCredential object. - -## PARAMETERS - -### -credential -Valid credentials to connect to the Zerto Management Server - -```yaml -Type: PSCredential -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -returnHeaders -Use this switch to return the headers to a specified variable or to the default output. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -zertoPort -Zerto Virtual Manager management port. -Default value is 9669. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: port - -Required: False -Position: 1 -Default value: "9669" -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -zertoServer -IP address or FQDN of your Zerto Management Server - -```yaml -Type: String -Parameter Sets: (All) -Aliases: server, zvm - -Required: True -Position: 0 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### None -## OUTPUTS - -### System.Object -## NOTES - -## RELATED LINKS - -[Zerto REST API Session End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/index.html#page/RestfulAPIs%2FStatusAPIs.5.068.html%23) - -[PSCredential Documentation](https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.pscredential?view=pscore-6.0.0) - -[Get-Credential Documentation](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-credential?view=powershell-6) +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Connect-ZertoServer.md +schema: 2.0.0 +--- + +# Connect-ZertoServer + +## SYNOPSIS +Establishes a connection to a ZVM. + +## SYNTAX + +``` +Connect-ZertoServer [-zertoServer] [[-zertoPort] ] [-credential] + [-returnHeaders] [-AutoReconnect] [] +``` + +## DESCRIPTION +Establishes a connection to a ZVM using credentials provided via a PSCredential Object leveraging the Zerto Session API end point. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "9669" -credential $credential +``` + +Establishes a connection to ZVM 192.168.1.100 on port 9669 with supplied PSCredential object. + +### Example 2 +```powershell +PS C:\> Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "9669" -credential $credential -AutoReconnect +``` + +Establishes a connection to ZVM 192.168.1.100 on port 9669 with supplied PSCredential object. Adding the `-AutoReconnect` switch +will cache the PSCredential object should the session need to be reauthorized due to an expired token. + +## PARAMETERS + +### -AutoReconnect +Use this switch to indicate that you would like the module to take care of auto re-authorization and reconnection to the ZVM should the token expire. This option will cache your PSCredential object to be reused + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -credential +Valid credentials to connect to the Zerto Management Server + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -returnHeaders +Use this switch to return the headers to a specified variable or to the default output. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zertoPort +Zerto Virtual Manager management port. +Default value is 9669. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: port + +Required: False +Position: 1 +Default value: "9669" +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zertoServer +IP address or FQDN of your Zerto Management Server + +```yaml +Type: String +Parameter Sets: (All) +Aliases: server, zvm + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS + +[Zerto REST API Session End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/index.html#page/RestfulAPIs%2FStatusAPIs.5.068.html%23) + +[PSCredential Documentation](https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.pscredential?view=pscore-6.0.0) + +[Get-Credential Documentation](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-credential?view=powershell-6) From f4c1cf630ab33728418f6680cc7eccf4d454c6a3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 11 Jun 2020 15:53:53 -0400 Subject: [PATCH 19/38] Moved Credential to Second Position --- ZertoApiWrapper/Public/Connect-ZertoServer.ps1 | 6 ++++-- docs/Connect-ZertoServer.md | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 9a8c649..20c0a7b 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -5,7 +5,8 @@ function Connect-ZertoServer { param( [Parameter( Mandatory, - HelpMessage = "IP address or FQDN of your Zerto Management Server" + HelpMessage = "IP address or FQDN of your Zerto Management Server", + Position = 0 )] [ValidateNotNullOrEmpty()] [Alias("server", "zvm")] @@ -19,7 +20,8 @@ function Connect-ZertoServer { [string]$zertoPort = "9669", [Parameter( Mandatory, - HelpMessage = "Valid credentials to connect to the Zerto Management Server" + HelpMessage = "Valid credentials to connect to the Zerto Management Server", + Position = 1 )] [System.Management.Automation.PSCredential]$credential, [switch]$returnHeaders, diff --git a/docs/Connect-ZertoServer.md b/docs/Connect-ZertoServer.md index ad36a82..9110133 100644 --- a/docs/Connect-ZertoServer.md +++ b/docs/Connect-ZertoServer.md @@ -13,8 +13,8 @@ Establishes a connection to a ZVM. ## SYNTAX ``` -Connect-ZertoServer [-zertoServer] [[-zertoPort] ] [-credential] - [-returnHeaders] [-AutoReconnect] [] +Connect-ZertoServer [-zertoServer] [-zertoPort ] [-credential] [-returnHeaders] + [-AutoReconnect] [] ``` ## DESCRIPTION @@ -63,7 +63,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 2 +Position: 1 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -94,7 +94,7 @@ Parameter Sets: (All) Aliases: port Required: False -Position: 1 +Position: Named Default value: "9669" Accept pipeline input: False Accept wildcard characters: False From 363b6e727c5e1632909a8981d0998015dd98d2e6 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 11 Jun 2020 16:16:38 -0400 Subject: [PATCH 20/38] Update Param Order Syntax in Help File --- docs/Connect-ZertoServer.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Connect-ZertoServer.md b/docs/Connect-ZertoServer.md index 9110133..e1bb8fd 100644 --- a/docs/Connect-ZertoServer.md +++ b/docs/Connect-ZertoServer.md @@ -13,8 +13,8 @@ Establishes a connection to a ZVM. ## SYNTAX ``` -Connect-ZertoServer [-zertoServer] [-zertoPort ] [-credential] [-returnHeaders] - [-AutoReconnect] [] +Connect-ZertoServer [-zertoServer] [-credential] [-zertoPort ] [-returnHeaders] +[] ``` ## DESCRIPTION From 2d453ef608816288d4489c572fef367fbf8a6102 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 11 Jun 2020 16:34:04 -0400 Subject: [PATCH 21/38] Put params in correct order --- .../Public/Connect-ZertoServer.ps1 | 20 +++++++++++-------- docs/Connect-ZertoServer.md | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 20c0a7b..49ec0f6 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -11,6 +11,12 @@ function Connect-ZertoServer { [ValidateNotNullOrEmpty()] [Alias("server", "zvm")] [string]$zertoServer, + [Parameter( + Mandatory, + HelpMessage = "Valid credentials to connect to the Zerto Management Server", + Position = 1 + )] + [System.Management.Automation.PSCredential]$credential, [Parameter( HelpMessage = "Zerto Virtual Manager management port. Default value is 9669." )] @@ -18,17 +24,15 @@ function Connect-ZertoServer { [ValidateRange(1024, 65535)] [Alias("port")] [string]$zertoPort = "9669", - [Parameter( - Mandatory, - HelpMessage = "Valid credentials to connect to the Zerto Management Server", - Position = 1 - )] - [System.Management.Automation.PSCredential]$credential, - [switch]$returnHeaders, [Parameter( HelpMessage = "Use this switch to indicate that you would like the module to take care of auto re-authorization and reconnection to the ZVM should the token expire. This option will cache your PSCredential object to be reused" )] - [switch]$AutoReconnect + [switch]$AutoReconnect, + [Parameter( + HelpMessage = "Use this switch to return the headers to a specified variable or to the default output." + )] + [switch]$returnHeaders + ) begin { diff --git a/docs/Connect-ZertoServer.md b/docs/Connect-ZertoServer.md index e1bb8fd..9a08e8d 100644 --- a/docs/Connect-ZertoServer.md +++ b/docs/Connect-ZertoServer.md @@ -13,8 +13,8 @@ Establishes a connection to a ZVM. ## SYNTAX ``` -Connect-ZertoServer [-zertoServer] [-credential] [-zertoPort ] [-returnHeaders] -[] +Connect-ZertoServer [-zertoServer] [-credential] [-zertoPort ] [-AutoReconnect] + [-returnHeaders] [] ``` ## DESCRIPTION From 7ce6369ad7063220fd5e6bea9974be59c7e82130 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 12 Jun 2020 12:39:38 -0400 Subject: [PATCH 22/38] Add tests for switches --- Tests/Public/Connect-ZertoServer.Tests.ps1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index 6d6e185..f417346 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -1,6 +1,6 @@ #Requires -Modules Pester $global:here = (Split-Path -Parent $PSCommandPath) -$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] +$global:function = ((Split-Path -Leaf $PSCommandPath).Split('.'))[0] Describe $global:function -Tag 'Unit', 'Source', 'Built' { BeforeAll { @@ -45,6 +45,16 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' { { Connect-ZertoServer -zertoServer -credential 1234 } | Should -Throw { Connect-ZertoServer -zertoServer -credential $(@{Username = "zerto\build"; Password = 'SecureString' }) } | Should -Throw } + + It "has a switch parameter to return the headers" { + Get-Command $global:function | Should -HaveParameter returnHeaders + Get-Command $global:function | Should -HaveParameter returnHeaders -Type Switch + } + + It "has a switch parameter to auto reauthorize the session" { + Get-Command $global:function | Should -HaveParameter autoReconnect + Get-Command $global:function | Should -HaveParameter autoReconnect -Type Switch + } } InModuleScope -ModuleName ZertoApiWrapper { From 6903ccc99b3fb8c9f711bb5b66e1fd33a543f484 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 22 Jun 2020 17:03:32 -0400 Subject: [PATCH 23/38] Update CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4a119..fb39f98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project is transitioning to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Zerto Virtual Manager + +#### Updated + +* Updated `Connect-ZertoServer` with a `-AutoReconnect` switch to allow the auto reconnection of a session that has timed-out. + ## [1.4.2] ### Zerto Virtual Manager From ddae22fb9fd55c8aa93c61df00100a711bb9488a Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 22 Jun 2020 17:18:16 -0400 Subject: [PATCH 24/38] Specify defaultParameterSetName --- ZertoApiWrapper/Public/New-ZertoVpg.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index 4ae6f60..f62ff30 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function New-ZertoVpg { - [cmdletbinding(SupportsShouldProcess = $true)] + [cmdletbinding(SupportsShouldProcess = $true, DefaultParameterSetName = "recoveryHostDatastore")] param( [Parameter( HelpMessage = "Name of the VPG", From ea8d6f096da7e0bb95824e331735a341e795facd Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 22 Jun 2020 17:18:40 -0400 Subject: [PATCH 25/38] Update Parameter with Proper Names --- ZertoApiWrapper/Public/New-ZertoVpg.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index f62ff30..d9d5d56 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -182,18 +182,18 @@ function New-ZertoVpg { # Get identifiers based on parameter set name switch ($PSCmdlet.ParameterSetName) { "recoveryClusterDatastoreCluster" { - $identifiersTable['clusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hostclusters | Where-Object { $_.VirtualizationClusterName -like $recoveryCluster }).ClusterIdentifier - $identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreclusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier + $identifiersTable['clusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hostClusters | Where-Object { $_.VirtualizationClusterName -like $recoveryCluster }).ClusterIdentifier + $identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreClusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier } "recoveryClusterDatastore" { - $identifiersTable['clusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hostclusters | Where-Object { $_.VirtualizationClusterName -like $recoveryCluster }).ClusterIdentifier + $identifiersTable['clusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hostClusters | Where-Object { $_.VirtualizationClusterName -like $recoveryCluster }).ClusterIdentifier $identifiersTable['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object { $_.DatastoreName -like $datastore }).DatastoreIdentifier } "recoveryHostDatastoreCluster" { $identifiersTable['recoveryHostIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hosts | Where-Object { $_.VirtualizationHostName -like $recoveryHost }).HostIdentifier - $identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreclusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier + $identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreClusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier } "recoveryHostDatastore" { @@ -202,12 +202,12 @@ function New-ZertoVpg { } "recoveryResourcePoolDatastoreCluster" { - $identifiersTable['recoveryResourcePoolIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -resourcepools | Where-Object { $_.ResourcePoolName -like $recoveryResourcePool }).ResourcePoolIdentifier - $identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreclusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier + $identifiersTable['recoveryResourcePoolIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -resourcePools | Where-Object { $_.ResourcePoolName -like $recoveryResourcePool }).ResourcePoolIdentifier + $identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreClusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier } "recoveryResourcePoolDatastore" { - $identifiersTable['recoveryResourcePoolIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -resourcepools | Where-Object { $_.ResourcePoolName -like $recoveryResourcePool }).ResourcePoolIdentifier + $identifiersTable['recoveryResourcePoolIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -resourcePools | Where-Object { $_.ResourcePoolName -like $recoveryResourcePool }).ResourcePoolIdentifier $identifiersTable['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object { $_.DatastoreName -like $datastore }).DatastoreIdentifier } } From 0f1b4302bb51745f07c65d8d64d959072ee33045 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 22 Jun 2020 17:18:55 -0400 Subject: [PATCH 26/38] Update CHANGELOG with latest updates --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb39f98..e65cefb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project is transitioning to [Semantic Versioning](https://semver.org/sp #### Updated * Updated `Connect-ZertoServer` with a `-AutoReconnect` switch to allow the auto reconnection of a session that has timed-out. +* Updated `New-ZertoVpg` to have a Default Parameter Set of `recoveryHostDatastore` should no parameters be passed when calling the function. ## [1.4.2] From 7fc7edff86f225b2aee31d12d7c36e0e57ac711f Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 23 Jun 2020 12:51:33 -0400 Subject: [PATCH 27/38] Update PeerSite Lookup Method --- ZertoApiWrapper/Public/New-ZertoVpg.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index d9d5d56..710f51d 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -165,7 +165,7 @@ function New-ZertoVpg { begin { # Create an identifiers table, and start converting names to identifiers. $identifiersTable = @{ } - $identifiersTable['recoverySiteIdentifier'] = $(Get-ZertoPeerSite -peerName $recoverySite).siteIdentifier + $identifiersTable['recoverySiteIdentifier'] = (Get-ZertoPeerSite).Where({$_.PeerSiteName -like $recoverySite}) | Select-Object -ExpandProperty SiteIdentifier $peerSiteNetworks = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -networks) $identifiersTable['failoverNetworkIdentifier'] = $peerSiteNetworks | Where-Object { $_.VirtualizationNetworkName -like $recoveryNetwork } | Select-Object -ExpandProperty NetworkIdentifier $identifiersTable['testNetworkIdentifier'] = $peerSiteNetworks | Where-Object { $_.VirtualizationNetworkName -like $testNetwork } | Select-Object -ExpandProperty NetworkIdentifier From 5627992a047053eddb6ed8064fe1332d1936c585 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 23 Jun 2020 12:54:03 -0400 Subject: [PATCH 28/38] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e65cefb..637870c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project is transitioning to [Semantic Versioning](https://semver.org/sp * Updated `Connect-ZertoServer` with a `-AutoReconnect` switch to allow the auto reconnection of a session that has timed-out. * Updated `New-ZertoVpg` to have a Default Parameter Set of `recoveryHostDatastore` should no parameters be passed when calling the function. +* Updated `New-ZertoVpg -recoverySite` parameter to be case-insensitive ## [1.4.2] From a25bf3adfe8ab407cda09286640fec150f362225 Mon Sep 17 00:00:00 2001 From: NScuola <15016465+NScuola@users.noreply.github.com> Date: Wed, 1 Jul 2020 14:06:30 -0400 Subject: [PATCH 29/38] Adding port information for pairing v7.5+ Adding port information to example for pairing v7.5+. --- docs/Add-ZertoPeerSite.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Add-ZertoPeerSite.md b/docs/Add-ZertoPeerSite.md index 7fafff4..72d82c2 100644 --- a/docs/Add-ZertoPeerSite.md +++ b/docs/Add-ZertoPeerSite.md @@ -31,10 +31,10 @@ Pairs the current Zerto Virtual Manager to the Zerto Virtual Manager at IP addre ### Example 2 ```powershell -PS C:\> Add-ZertoPeerSite -targetHost "192.168.2.100" -token "GeneratedFromTargetZVM" +PS C:\> Add-ZertoPeerSite -targetHost "192.168.2.100" -targetPort "9071" -token "GeneratedFromTargetZVM" ``` -Pairs the current Zerto Virtual Manager to the Zerto Virtual Manager at IP address 192.168.2.100. Use this method when pairing Zerto Virtual Managers that are version 7.5 or later. +Pairs the current Zerto Virtual Manager to the Zerto Virtual Manager at IP address 192.168.2.100 over Port 9071. Use this method when pairing Zerto Virtual Managers that are version 7.5 or later. ## PARAMETERS From 41fddf5f13fde3836df623003cb49e50cca019c9 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 1 Jul 2020 17:09:38 -0400 Subject: [PATCH 30/38] Set-ZertoLicense - Fix ShouldProcess error Fixes #96 --- ZertoApiWrapper/Public/Set-ZertoLicense.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 b/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 index aa95042..90fdd47 100644 --- a/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 +++ b/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 @@ -16,7 +16,7 @@ function Set-ZertoLicense { } process { - if ($PSCmdlet.ShouldProcess()) { + if ($PSCmdlet.ShouldProcess("Applying License Key: $licenseKey to server: $($script:zvmServer)")) { Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "PUT" } } From a072905253596e2a3a226ac5ce8b9006c39a5f51 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 1 Jul 2020 17:34:25 -0400 Subject: [PATCH 31/38] Update ChangLog with Issue 96 updates --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 637870c..36f9447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ and this project is transitioning to [Semantic Versioning](https://semver.org/sp * Updated `New-ZertoVpg` to have a Default Parameter Set of `recoveryHostDatastore` should no parameters be passed when calling the function. * Updated `New-ZertoVpg -recoverySite` parameter to be case-insensitive +#### Fixed + +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/96) with `Set-ZertoLicense` so that ShouldProcess functions properly. + ## [1.4.2] ### Zerto Virtual Manager From 713c94461c0b4f3a72390027f0c62227072d92ff Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 6 Jul 2020 14:25:43 -0400 Subject: [PATCH 32/38] Replace Script Scope LocalSite Info Variable --- ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 | 2 +- ZertoApiWrapper/Public/Install-ZertoVra.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 index d76e96c..68a20f4 100644 --- a/ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 @@ -2,6 +2,6 @@ function Get-ZertoUnprotectedVm { [cmdletbinding()] param() - $uri = "virtualizationsites/{0}/vms" -f $script:zvmLocalInfo.siteidentifier + $uri = "virtualizationsites/{0}/vms" -f (Get-ZertoLocalSite).siteIdentifier Invoke-ZertoRestRequest -uri $uri } diff --git a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 index 70f74a5..3ce61d2 100644 --- a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 @@ -111,7 +111,7 @@ function Install-ZertoVra { # If the VRA does not exist, proceed with the installation. If it does exist, bypass and if ( -not (Get-ZertoVra -vraName $vraName) ) { # Get identifiers for each item provided by name. - $siteIdentifier = $script:zvmLocalInfo.SiteIdentifier + $siteIdentifier = (Get-ZertoLocalSite).SiteIdentifier $hostIdentifier = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -hosts | Where-Object { $_.VirtualizationHostName -eq $hostName } | Select-Object hostIdentifier -ExpandProperty hostIdentifier $networkIdentifier = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -networks | Where-Object { $_.VirtualizationNetworkName -eq $networkName } | Select-Object NetworkIdentifier -ExpandProperty NetworkIdentifier $datastoreIdentifier = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -datastores | Where-Object { $_.DatastoreName -eq $datastoreName } | Select-Object DatastoreIdentifier -ExpandProperty DatastoreIdentifier From 7427ffe70709152df9bc97741d71ba37a020bd1d Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 6 Jul 2020 14:26:10 -0400 Subject: [PATCH 33/38] Remove operation to set ZvmLocalInfo Variable --- ZertoApiWrapper/Public/Connect-ZertoServer.ps1 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 49ec0f6..237f845 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -62,10 +62,7 @@ function Connect-ZertoServer { end { # Build Headers Hashtable with Authorization Token $Script:zvmHeaders['x-zerto-session'] = $results.Headers['x-zerto-session'][0].ToString() - # Set common Script Scope Variables to be used other functions (Headers and Local Site Info) - # Set-Variable -Name zvmHeaders -Scope Script -Value $zertoAuthorizationHeaders - Set-Variable -Name zvmLocalInfo -Scope Script -Value (Get-ZertoLocalSite) - + # Have the option to return the headers to a variable if ($returnHeaders) { return $Script:zvmHeaders From 8318229cf43bf6522470398f70de157c09b0ec9e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 6 Jul 2020 14:26:36 -0400 Subject: [PATCH 34/38] Remove Removal of Variable no longer required --- ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 index b9d3032..080ec50 100644 --- a/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 @@ -12,5 +12,4 @@ function Disconnect-ZertoServer { Remove-Variable -Name zvmPort -Scope Script Remove-Variable -Name zvmLastAction -Scope Script Remove-Variable -Name zvmHeaders -Scope Script - Remove-Variable -Name zvmLocalInfo -Scope Script } From 494c45b02c838c5cd45344cbcc42a4f6025f361a Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 6 Jul 2020 14:26:56 -0400 Subject: [PATCH 35/38] Remove tests for removed variable --- Tests/Public/Connect-ZertoServer.Tests.ps1 | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index f417346..7b0519d 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -106,12 +106,6 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' { $script:zvmHeaders['Accept'] | Should -BeOfType String } - It "Module Scope zvmLocalInfo variable tests" { - $script:zvmLocalInfo | Should -Not -BeNullOrEmpty - $script:zvmLocalInfo | Should -BeOfType PSCustomObject - $script:zvmLocalInfo.SiteIdentifier | Should -BeOfType String - } - $headers = Connect-ZertoServer -zertoServer $Server -credential $credential -returnHeaders It "returns a Hashtable with 2 keys" { $headers | Should -BeOfType Hashtable From c477d40364a591583e7f697f4eccf521151fa287 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 6 Jul 2020 14:30:07 -0400 Subject: [PATCH 36/38] Remove Mocks that are not required any longer --- Tests/Public/Connect-ZertoServer.Tests.ps1 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index 7b0519d..802cc9b 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -67,10 +67,6 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' { return $results } - Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite { - return (Get-Content -Path "$global:here\Mocks\LocalSiteInfo.json" -Raw | ConvertFrom-Json) - } - Context "$($global:function)::InModuleScope Function Unit Tests" { BeforeAll { @@ -138,7 +134,6 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' { } Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 4 - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite -Exactly 4 } } } From 5a2c01341ce3553c736a9d0c6d17f945a4f00d6e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 6 Jul 2020 14:32:32 -0400 Subject: [PATCH 37/38] Update Changlog for Issue 95 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36f9447..16d0945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project is transitioning to [Semantic Versioning](https://semver.org/sp #### Fixed * Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/96) with `Set-ZertoLicense` so that ShouldProcess functions properly. +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/95) when attempting to connect to an unlicensed site. ## [1.4.2] From 3621ddef8dedc44fa53c26e3ac5943fed8080fa8 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 8 Jul 2020 13:08:49 -0400 Subject: [PATCH 38/38] Set Version Numbers --- CHANGELOG.md | 2 +- version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16d0945..341c6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project is transitioning to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [1.4.3] ### Zerto Virtual Manager diff --git a/version.txt b/version.txt index 9df886c..428b770 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.4.2 +1.4.3