diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..4006efc --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,62 @@ +# How to contribute + +Contributions to ZertoApiWrapper are highly encouraged and desired. +Below are some guidelines that will help make the process as smooth as possible. + +## Getting Started + +- Make sure you have a [GitHub account](https://github.com/signup/free) +- Submit a new issue, assuming one does not already exist. + - Clearly describe the issue including steps to reproduce when it is a bug. + - Make sure you fill in the earliest version that you know has the issue. +- Fork the repository on GitHub + +## Suggesting Enhancements + +I want to know what you think is missing from ZertoApiWrapper and how it can be made better. + +- When submitting an issue for an enhancement, please be as clear as possible about why you think the enhancement is needed and what the benefit of it would be. + +## Making Changes + +- From your fork of the repository, create a topic branch where work on your change will take place. +- To quickly create a topic branch based on master; `git checkout -b my_contribution master`. + Please avoid working directly on the `master` branch. +- Make commits of logical units. +- Check for unnecessary whitespace with `git diff --check` before committing. +- Please follow the prevailing code conventions in the repository. + Differences in style make the code harder to understand for everyone. +- Make sure your commit messages are in the proper format. + +``` + Add more cowbell to Get-Something.ps1 + + The functionality of Get-Something would be greatly improved if there was a little + more 'pizzazz' added to it. I propose a cowbell. Adding more cowbell has been + shown in studies to both increase one's mojo, and cement one's status + as a rock legend. +``` + +- Make sure you have added all the necessary Pester tests for your changes. +- Run _all_ Pester tests in the module to assure nothing else was accidentally broken. + +## Documentation + +I am infallible and as such my documenation needs no corectoin. +In the highly unlikely event that that is _not_ the case, commits to update or add documentation are highly apprecaited. + +## Submitting Changes + +- Push your changes to a topic branch in your fork of the repository. +- Submit a pull request to the main repository. +- Once the pull request has been reviewed and accepted, it will be merged with the master branch. +- Celebrate + +## Additional Resources + +- [General GitHub documentation](https://help.github.com/) +- [GitHub forking documentation](https://guides.github.com/activities/forking/) +- [GitHub pull request documentation](https://help.github.com/send-pull-requests/) +- [GitHub Flow guide](https://guides.github.com/introduction/flow/) +- [GitHub's guide to contributing to open source projects](https://guides.github.com/activities/contributing-to-open-source/) + diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..28202e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,31 @@ + + +## Expected Behavior + + + +## Current Behavior + + + +## Possible Solution + + + +## Steps to Reproduce (for bugs) + + +1. +2. +3. +4. + +## Context + + + +## Your Environment + +* Module version used: +* Operating System and PowerShell version: +* Zerto Virtual Manager Version: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..52edb2a --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,37 @@ + + +## Description + + +## Related Issue + + + + + +## Motivation and Context + + +## How Has This Been Tested? + + + + +## Screenshots (if appropriate): + +## Types of changes + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to change) + +## Checklist: + + +- [ ] My code follows the code style of this project. +- [ ] My change requires a change to the documentation. +- [ ] I have updated the documentation accordingly. +- [ ] I have read the **CONTRIBUTING** document. +- [ ] I have added tests to cover my changes. +- [ ] All new and existing tests passed. + diff --git a/.gitignore b/.gitignore index 2f58130..614cba9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ *.zip temp/* -Tests/Public/TestResults.xml -Tests/TestResults.xml +BuiltTestResults.xml +SourceTestResults.xml publish/* CodeCoverage.xml +scratch +.DS_Store diff --git a/.vscode/settings.json b/.vscode/settings.json index d6dea32..1b91392 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,9 @@ { "files.trimTrailingWhitespace": true, - "terminal.integrated.shell.windows": "c:/Program Files/PowerShell/6/pwsh.exe" + "files.insertFinalNewline": true, + "editor.insertSpaces": true, + "editor.tabSize": 4, + "powershell.codeFormatting.preset": "OTBS", + "terminal.integrated.shell.windows": "c:/Program Files/PowerShell/7/pwsh.exe", + "powershell.codeFormatting.addWhitespaceAroundPipe": true } diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1ff98e1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,159 @@ +# Changelog + +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). + +## [1.5.3] + +### Zerto Virtual Manager + +#### Fixed + +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/112) where `New-ZertoVpg` would fail when specifying the local site as the target site. +* Updated the method where a Site Identifer is obtained during the `New-ZertoVpg` execution that would occasionally fail on some versions of PowerShell. + +#### Updated + +* Updated `New-ZertoVpg` function [help documentation](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/New-ZertoVpg.md) to more clearly specify the return value and the requirement to pass it into the `Save-ZertoVpgSetting` function to commit the VPG. + +## [1.5.2] + +### Zerto Virtual Manager + +#### Fixed + +* Fixed an issue when attempting to export more than 100 VPGs with the `Export-ZertoVpg` function that would cause an error. + +## [1.5.1] + +### Zerto Virtual Manager + +#### Fixed + +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/108) with `New-ZertoVpg` where when specifying a single host as a recovery target, the host identifier was not properly assigned. - Thanks @jonsouzerto! +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/86) with `Invoke-ZertoMoveVpg` where parameters should have been mandatory in certain workflows. - Thanks @gdbarron! + +## [1.5.0] + +### Zerto Virtual Manager + +#### New + +* Added `Add-ZertoVpgVm` function to the module. Read the [help file](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Add-ZertoVpgVm.md) for more information. +* Added `Remove-ZertoVpgVm` function to the module. Read the [help file](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Remove-ZertoVpgVm.md) for more information. + +#### Fixed + +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/103) with `Add-ZertoPeerSite` where there was an incorrect settings validator on the `-targetHost` parameter where it would not accept a hostname. + +## [1.4.3] + +### Zerto Virtual Manager + +#### 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. +* 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. +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/95) when attempting to connect to an unlicensed site. + +## [1.4.2] + +### Zerto Virtual Manager + +#### Fixed + +* Updated `Get-ZertoEvent` to translate a vpg name parameter to a vpgIdentifier per the API documentation +* Updated `Invoke-ZertoMoveCommit` to ensure that when one of the parameter switches is defined, all required parameters are sent to avoid conflicts with parameters passed with the `Invoke-ZertoMove` command. +* Updated `Start-ZertoCloneVpg` to fix an issue where an error would be thrown if an operation specified a subset of VMs to be cloned. + +## [1.4.1] + +### General + +* Removed RELEASENOTES and converted to a CHANGELOG format. +* Updated the build process to follow Semantic Versioning. +* Updated the build process to use the latest Pester Version (4.10.1) +* Updated the build process to use the latest PS Script Analyzer Version (1.19.0) +* Updated the Tests Files to use a more modern method of grabbing the PSScriptPath + +### Zerto Virtual Manager + +* Refactored `Copy-ZertoVpg` functionality to leverage identifier and name maps and eliminate `where-object` searches. +* Updated `Get-ZertoEvent` parameter to fall in line with the filter parameter name in the API documentation. Moved the old parameter name to an alias to ensure that existing functionality continues to work. + +## [1.4.0.20200410] + +### Zerto Virtual Manager + +* Addressed a reported [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/60) in the `Get-ZertoRecoveryReport` function where the `-VpgIdentifier` parameter was not working. This parameter is not accepted by the API as a valid filter and is ignored. This parameter has been removed from the function. +* Addressed a reported [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/61) where the `Export-ZertoVpgNicSetting` function would not properly execute when run against a VM with no NICs attached. +* In reviewing the `Export-ZertoVpgNicSetting`, a review of the `Import-ZertoVpgNicSetting` was completed and it was determined to update the import logic based on various test cases. Along with this, it is now possible to reset the NIC settings to the default state with the `Import-ZertoVpgNicSetting` command. Please review the [Import-ZertoVpgNicSetting help](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Import-ZertoVmNicSetting.md) to review the updated options and import logic. +* Refactored the `Checkpoint-ZertoVpg` command to allow pipeline input (ByValue and ByProperty) for the VpgName parameter. +* Corrected a parameter typo in the `Get-ZertoVpgSetting` function. The misspelt parameter was added as an alias to ensure any existing scripts using the parameter continue to function. +* Refactored the `Get-ZertoVpg` command to remove repetitive commands and variables that are no longer required. +* Moved `Invoke-ZertoRestRequest` and `Invoke-ZARestRequest` to be public functions. As there become more and more scenarios where there are not prebuilt functions to accomplish complex specialized tasks, it became apparent that these functions could be leveraged to make the experience and workflow easier. +* Updated the `Install-ZertoVra` logic to ensure that the target datastore is available on the target host. There isn't currently any method to validate the target network, but if that becomes available in a later version of the API, the function will be updated. +* Updated the `Install-ZertoVra` function to allow for installation of the VRA using the host password method. Please review the [Install-ZertoVra](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Install-ZertoVra.md) documentation for syntax and examples. +* Updated the `Edit-ZertoVra` function to allow for modification of the associated ESX host password if the need arises. Please review the [Edit-ZertoVra](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Edit-ZertoVra.md) documentation for syntax and examples. +* Added a new function, `Set-ZertoUserCredential`, to allow the updating of the username and password used to connect the Zerto Virtual Manager to the paired hypervisor. Please see the [Set-ZertoUserCredential](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Set-ZertoUserCredential.md) help for additional information. +* With the release of [Zerto 8.0](https://www.zerto.com/zerto-8-0-general-availability/) some additional API endpoints have become available. + * Updated `Get-ZertoVirtualizationSite` to add the `-repository` parameter to enable returning information for LTR repositories. + * Updated `Get-ZertoVpgSetting` to add the `-ltr` parameter to enable returning information for current LTR settings for the selected VPG. + +### Zerto Analytics + +* Added several functions for the newly added [Zerto Analytics](https://analytics.zerto.com) Planner. + * `Get-ZAPlannerSite` Help can be found here: [Get-ZAPlannerSite](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerSite.md) + * `Get-ZAPlannerStatsReport` Help can be found here: [Get-ZAPlannerStatsReport](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerStatsReport.md) + * `Get-ZAPlannerJournalSizeReport` Help can be found here: [Get-ZAPlannerJournalSizeReport](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerJournalSizeReport.md) + * `Get-ZAPlannerNetworkPerformanceReport` Help can be found here: [Get-ZAPlannerNetworkPerformanceReport](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerNetworkPerformanceReport.md) + * `Get-ZAPlannerWanReport` Help can be found here: [Get-ZAPlannerWanReport](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerWanReport.md) + * `Get-ZAPlannerZcasReport` Help can be found here: [Get-ZAPlannerZcasReport](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerZcasReport.md) +* Created `Get-ZAProtectedVm` and `Get-ZAProtectedVmReport` functions to leverage the newly released Zerto Analytics APIs for this data. Help files can be found here: [Get-ZAProtectedVm](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAProtectedVm.md) and [Get-ZAProtectedVmReport](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAProtectedVmReport.md) + +## [1.3.0.20191201] + +### Zerto Virtual Manager + +* [Zerto version 7.5 has been released.](https://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Release%20Notes.pdf) As part of this release Zerto has added API functionality that requires the following updates. + * A token is now required to pair two sites together. The need is discussed in [Issue 46](https://github.com/ZertoPublic/ZertoApiWrapper/issues/46). To implement this change a `-token` parameter has been added to the `Add-ZertoPeerSite` function. + * A new function has been added; `New-ZertoPairingToken`. This function will allow users to generate a pairing authentication token from the target ZVM to be used in the pairing process. [Issue 47](https://github.com/ZertoPublic/ZertoApiWrapper/issues/47) covers additional details. +* A new function has been added; `Invoke-ZertoEvacuateVra`. This function will allow users to evacuate a target VRA by specifying a Host Name, VRA Name, or VRA Identifier. All VMs currently replicating to the specified location will be migrated to different targets. [Issue 51](https://github.com/ZertoPublic/ZertoApiWrapper/issues/51) +* A function has been added; `Copy-ZertoVpg`. This function will allow users to copy the settings of a single VPG and add new VMs to it. There is currently no customization beyond specifying the VMs to be placed in the newly created VPG. Should additional edits \ updates be required, they should be done post creation. [Issue 54](https://github.com/ZertoPublic/ZertoApiWrapper/issues/54) +* Fixed [issue 57](https://github.com/ZertoPublic/ZertoApiWrapper/issues/57) where a `Start-ZertoFailoverTest` would throw an error complaining about validating the body parameter. This has been fixed and tested against Zerto Virtual Manager 7.5 Update 1 with Windows PowerShell 5.1 and PowerShell Core 6.2. + +## [1.2.0.20190801] + +### Zerto Virtual Manager + +* Added two functions to aid in bulk updating of NIC information for protected VMs. ([Issue 38](https://github.com/ZertoPublic/ZertoApiWrapper/issues/38)) + * [Export-ZertoVmNicSetting](https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Export-ZertoVmNicSettings.md) + * [Import-ZertoVmNicSetting](https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Import-ZertoVmNicSettings.md) +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/43) where a VPG being created with a single VM member would not be parsed by the API correctly using PowerShell 5.1 + +### Zerto Analytics + +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/36) where the Zerto Analytics Rest Request function was not checking for the token before attempting a connection. +* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/40) where the `Get-ZAVpg` method would return a 404 error when a `-vpgIdentifier` parameter was specified. + +### General Updates + +* Updated the way that tests are invoked and parsed to ensure that both source and built module files are tested. This will ensure that what is being shipped passes all tests along with testing of the source files. +* Added additional parameter validation tests to several of the functions. On-going effort to complete stand alone unit testing of each function. + +## [Initial Release] + +### Zerto Virtual Manager + +* Updated `Invoke-ZertoRestRequest` to work in Powershell 5.1 as well as Powershell core + +### Zerto Analytics + +* Implemented Zerto Analytics Functionality. Please see [Getting Started with Zerto Analytics](https://github.com/ZertoPublic/ZertoApiWrapper/wiki/Getting-Started-with-Zerto-Analytics) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..c79c49d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at technicalmarketing@zerto.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/README.md b/README.md index 0fa3a9a..65b5674 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # ZertoApiWrapper -PowerShell Core wrapper for Zerto Virtual Manager API +PowerShell wrapper for Zerto Virtual Manager API ## Current Build Status -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0e31e5cdad534271ac688a82cc3ca17d)](https://app.codacy.com/app/wcarroll/ZertoApiWrapper?utm_source=github.com&utm_medium=referral&utm_content=wcarroll/ZertoApiWrapper&utm_campaign=Badge_Grade_Settings) -[![Build Status](https://dev.azure.com/wescarroll/ZertoApiWrapper/_apis/build/status/wcarroll.ZertoApiWrapper?branchName=master)](https://dev.azure.com/wescarroll/ZertoApiWrapper/_build/latest?definitionId=1&branchName=master) +[![Build Status](https://dev.azure.com/ZertoPublic/ZertoApiWrapper/_apis/build/status/ZertoPublic.ZertoApiWrapper?branchName=master)](https://dev.azure.com/ZertoPublic/ZertoApiWrapper/_build/latest?definitionId=1&branchName=master) +[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/ZertoApiWrapper?label=PowerShell%20Gallery%20Downloads)](https://www.powershellgallery.com/packages/ZertoApiWrapper) ## Legal Disclaimer @@ -15,54 +15,30 @@ In no event shall Zerto, its authors or anyone else involved in the creation, pr ## Disclaimer -This code is still under development!! USE AT YOUR OWN RISK AND ONLY IF YOU KNOW WHAT YOU ARE DOING!! +This code is still under development! Please use carefully and if you encounter any issues or have an idea, please submit an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues). Along the same lines, should you be proficient in PowerShell, please feel free to submit any [Pull Requests](https://github.com/ZertoPublic/ZertoApiWrapper/pulls) with enhancements and bug fixes. + +## Installing the Module + +This module can be installed directly from the [PowerShell Gallery](https://www.powershellgallery.com/packages/ZertoApiWrapper) with the following command. + +```PowerShell +PS> Install-Module -name ZertoApiWrapper +``` ## Getting Started -Place the folder and contents on your hard drive in a location known to you. From there run the following command to import the module into your session: - -```PowerShell -PS C:\>Import-Module \ZertoApiWrapper\ZertoApiWrapper\ZertoApiWrapper.psm1 -force -``` - -This will import the module into your current session and make the function available to you use and test. - -### Connecting to a ZVM - -Before any of the functions will work, you will need to connect to a Zerto Virtual Manager server. To do this you will use the `Connect-ZertoServer` function passing in a Server Name or IP address of the Zerto Virtual Manager. If you are using a non-standard port, you will need to provide that as well with the `-zertoPort` parameter. You will also need to supply credentials to authenticate against the Zerto Virtual Manager. If credentials are not provided, the user will be prompted for a username and password. - -```PowerShell -PS C:\>$credential = Get-Credential -PS C:\>Connect-ZertoServer -zertoServer "192.168.222.20" -credential $credential -``` - -After successful execution, a few Module level variables are set that are not currently exposed. These variables keep track of the Zerto Server connection information such as Server Name and Port information along with the authentication headers. A "Last Action" variable is also set to keep track of when the last call was made to the API to determine if the authentication information has expired or not. Should this command be run again with a different server, the old information will be overwritten and all commands from that point will be executed against the new server information. - -### Using the Module - -A help system is currently under development. While each command has a help page, it may not be fully fleshed out yet. To see all possible functions you can use the following command after the module has been imported: - -```PowerShell -PS C:\>Get-Command -module ZertoApiWrapper -``` - -Once you have found the command that you want to know about you can call `Get-Help ` to take a look at the help page, or if you want to see syntax, `Get-Command -syntax`. - -### Ending the Session - -If you are using this as part of a larger script, I highly suggest explicitly ending your session with the `Disconnect-ZertoSession` command. This will delete the token authorization from the Zerto Virtual Manager as well as clear all Module scoped variables. +* [Getting Started with Zerto Virtual Manager and the ZertoApiWrapper](https://github.com/ZertoPublic/ZertoApiWrapper/wiki/Getting-Started-with-Zerto-Virtual-Manager) +* [Getting Started with Zerto Analytics and the ZertoApiWrapper](https://github.com/ZertoPublic/ZertoApiWrapper/wiki/Getting-Started-with-Zerto-Analytics) ## Recent Updates -- March 15th, 2019: Implement Export and Import Functionality. Please See [Export-ZertoVpg Help](https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Export-ZertoVpg.md) and [Import-ZertoVpg Help](https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Import-ZertoVpg.md) for assistance. No current pre-seed support. -- March 11th, 2019: Create basic VPG completed. Please see [New-ZertoVpg Help](https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/New-ZertoVpg.md) +All recent updates can now be tracked via the [Change Log](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/CHANGELOG.md). ## TODO -- Complete Help Markdown Files -- JFLR Functionality -- Create VPG (Per-VM modification and Backup Settings) -- Edit VPG -- Delete Zerto License -- Flesh out Pester Tests -- Complete Automated Build Process +* JFLR Functionality +* Create VPG (Per-VM modification and Backup Settings) +* Edit VPG +* Delete Zerto License +* Flesh out Pester Tests +* Complete Automated Build Process diff --git a/RELEASENOTES.md b/RELEASENOTES.md deleted file mode 100644 index cfd8e79..0000000 --- a/RELEASENOTES.md +++ /dev/null @@ -1,6 +0,0 @@ - - -* New Feature 1 -* New Feature 2 - * New SubFeature 1 -* What is happening??? diff --git a/Tests/Private/Get-Map.Tests.ps1 b/Tests/Private/Get-Map.Tests.ps1 new file mode 100644 index 0000000..040afda --- /dev/null +++ b/Tests/Private/Get-Map.Tests.ps1 @@ -0,0 +1,70 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + InModuleScope -ModuleName ZertoApiWrapper { + Context "$global:function::Parameter Unit Tests" { + It "have a mandatory parameter for the Input Object" { + Get-Command $global:function | Should -HaveParameter InputObject -Mandatory -Type PSCustomObject + } + + It "Input Object should not accecpt a Null or Empty value" { + $myObj = [PSCustomObject]@{ } + { Get-Map -InputObject $myObj -Key "Key" -Value "Value" } | Should Throw + { Get-Map -InputObject $null -Key "Key" -Value "Value" } | Should Throw + { Get-Map -InputObject "" -Key "Key" -Value "Value" } | Should Throw + } + + It "have a mandatory string parameter for the Map Key" { + Get-Command $global:function | Should -HaveParameter Key -Mandatory -Type String + } + + It "The Map variable should not accecpt a Null or Empty value" { + $myObj = [PSCustomObject]@{one = 1; two = 2 } + { Get-Map -InputObject $myObj -Key "" -Value "Value" } | Should Throw + { Get-Map -InputObject $null -Key $null -Value "Value" } | Should Throw + { Get-Map -InputObject $myObj -Key 1 -Value "Value" } | Should Throw + } + + It "The Value variable should not accecpt a Null or Empty value" { + $myObj = [PSCustomObject]@{one = 1; two = 2 } + { Get-Map -InputObject $myObj -Key "Key" -Value "" } | Should Throw + { Get-Map -InputObject $myObj -Key "Key" -Value $null } | Should Throw + { Get-Map -InputObject $myObj -Key "Key" -Value 1 } | Should Throw + } + + It "have a mandatory string parameter for the Map Value" { + Get-Command $global:function | Should -HaveParameter Value -Mandatory -Type String + } + + It "should have an Output type of Hashtable" { + (Get-Command $global:function).OutputType.Name | Should -Match "Hashtable" + } + } + + Context "$global:function::Function Tests" { + $myObj = Get-Content "$global:here/Mocks/ProtectedVMs.json" | ConvertFrom-Json + BeforeEach { + $MyMap = Get-Map -InputObject $MyObj -Key "vmIdentifier" -Value "vmName" + } + It "Returned object should be a hashtable" { + $myMap | Should -BeOfType Hashtable + } + + It "should return a hashtable with 3 entries" { + $myMap.count | Should -Be 3 + } + + It "should be properly mapped" { + $myMap["vmid.12"] | Should -Be "ExchangeMailbox" + $myMap["vmid.13"] | Should -Be "ExchangeApplication" + $myMap["vmid.14"] | Should -Be "ExchangeWeb" + } + } + } +} + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Private/Get-ZertoApiFilter.Tests.ps1 b/Tests/Private/Get-ZertoApiFilter.Tests.ps1 index 92af238..ce0fbfb 100644 --- a/Tests/Private/Get-ZertoApiFilter.Tests.ps1 +++ b/Tests/Private/Get-ZertoApiFilter.Tests.ps1 @@ -1,30 +1,74 @@ -$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' -$file = Get-ChildItem "$filePath\$fileName" +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -. $file.FullName -$singleBoolItemTest = @{"BoolItem" = $True} -$oneItemTest = @{"OneItem" = "Test"} -$twoItemTest = @{"OneItem" = "Test"; "SecondItem" = "Yours"} -$boolItemTest = @{"OneItem" = "Test"; "BoolItem" = $true} +Describe $global:function -Tag 'Unit', 'Source', 'Built' { -Describe $file.BaseName -Tag Unit { - it "file should exist" { - $file.Fullname | should exist - } + InModuleScope -ModuleName ZertoApiWrapper { + Context "$global:function::Parameter Unit Tests" { + It "has a mandatory hashtable parameter for the filterTable" { + Get-Command $global:function | Should -HaveParameter filterTable -Mandatory -Type Hashtable + } - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file.Fullname -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 - } + It "FilterTable should not accecpt a Null or Empty parameter" { + { Get-ZertoApiFilter -filtertable (@{ }) } | Should Throw + { Get-ZertoApiFilter -filtertable "" } | Should Throw + { Get-ZertoApiFilter -filtertable $null } | Should Throw + } - it "converts bool to text" { - Get-ZertoApiFilter -filtertable $singleBoolItemTest | should -Be "?BoolItem=True" + It "should have an Output type of String" { + (Get-Command $global:function).OutputType.Name | Should -Match "String" + } + } + + Context "$global:function::Function Unit Tests" { + BeforeAll { + $singleBoolItemTest = @{"BoolItem" = $True } + $oneItemTest = @{ OneItem = "Test" } + $twoItemTest = @{ + OneItem = "Test" + SecondItem = "Yours" + } + $commonParamTest = @{ + Debug = $True + ErrorAction = "Stop" + ErrorVariable = "ErrVar" + InformationAction = "Continue" + InformationVariable = "InfoVar" + OutVariable = "OutVar" + OutBuffer = "OutBuff" + PipelineVariable = "PipeVar" + Verbose = $false + WarningAction = "SilentlyContinue" + WarningVariable = "WarnVar" + WhatIf = $True + Confirm = $false + OneItem = "Test" + } + } + + It "converts bool to text" { + Get-ZertoApiFilter -filtertable $singleBoolItemTest | Should -Be "?BoolItem=True" + } + + It "one item test" { + Get-ZertoApiFilter -filtertable $oneItemTest | Should -Be "?OneItem=Test" + } + + It "should ignore CommonParameters" { + Get-ZertoApiFilter -filtertable $commonParamTest | Should -Be "?OneItem=Test" + } + + It "should process a filter table with more than one item" { + $returnString = Get-ZertoApiFilter -filtertable $twoItemTest + $returnString | Should -match "^\?" + $returnString | Should -match "&" + $returnString | Should -match "OneItem=Test" + $returnString | Should -match "SecondItem=Yours" + } + } } - it "one item test" { - Get-ZertoApiFilter -filtertable $oneItemTest | should be "?OneItem=Test" - } - #TODO:: Figure out multi-item tests } + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 b/Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 deleted file mode 100644 index 984d682..0000000 --- a/Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' -$file = Get-ChildItem "$filePath\$fileName" -. $file.FullName - -Describe $file.BaseName -Tag Unit { - it "file should exist" { - $file.FullName | should exist - } - - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file.FullName -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 - } -} \ No newline at end of file diff --git a/Tests/Private/Mocks/ProtectedVMs.json b/Tests/Private/Mocks/ProtectedVMs.json new file mode 100644 index 0000000..cf4924b --- /dev/null +++ b/Tests/Private/Mocks/ProtectedVMs.json @@ -0,0 +1,15 @@ +[ + { + "VMname": "ExchangeMailbox", + "VMIdentifier": "vmid.12" + }, + { + "VMName": "ExchangeApplication", + "VmIdentifier": "vmid.13" + }, + { + "VMName": "ExchangeWeb", + "VmIdentifier": "vmid.14" + } +] + diff --git a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 index a55ee59..81f590f 100644 --- a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 @@ -1,76 +1,94 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -Leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { - - It "Is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock } - Context "$($file.BaseName)::Parameter Unit Tests" { + Context "$global:function::Parameter Unit Tests" { - it "Has a mandatory string parameter for the target host" { - Get-Command $file.BaseName | Should -HaveParameter TargetHost -Mandatory -Type String + It "$global:function should have exactly 16 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 } - it "Will not take a non-ip address as a 'TargetHost'" { - {Add-ZertoPeerSite -targetHost 'MyZVMHost' -targetPort '9081'} | should -Throw - {Add-ZertoPeerSite -targetHost '192.168.1.266' -targetPort '9081'} | should -Throw - {Add-ZertoPeerSite -targetHost '192.168.1' -targetPort '9081'} | should -Throw - {Add-ZertoPeerSite -targetHost $null -targetPort '9081'} | should -Throw + $ParameterTestCases = @( + @{ParameterName = 'targetHost'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'targetPort'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + @{ParameterName = 'token'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type } - it "Has a non-mandatory string parameter for the target port with default value of 9081" { - Get-Command $file.BaseName | Should -HaveParameter TargetPort -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter TargetPort -Type Int32 - Get-Command $file.BaseName | Should -HaveParameter TargetPort -DefaultValue 9081 + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } } - it "Will not take a non-int as a port" { - {Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 'string'} | should -Throw - {Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $true} | should -Throw - {Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $null} | should -Throw + It "targetPort Parameter should have a default value of 9081" { + Get-Command $global:function | Should -HaveParameter targetPort -DefaultValue 9081 } - It "Will fail if the specified port is outside of the range 1024 - 65535" { - {Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 1023} | Should -Throw - {Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 65536} | Should -Throw - {Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 0} | Should -Throw - {Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort -1} | Should -Throw + It "targetPort Parameter should have a Min value of 1024" { + (Get-Command $global:function).Parameters['targetPort'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 1024 } - it "Supports 'SupportsShouldProcess'" { - Get-Command $file.BaseName | Should -HaveParameter WhatIf - Get-Command $file.BaseName | Should -HaveParameter Confirm - $file | Should -FileContentMatch 'SupportsShouldProcess' - $file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' + It "targetPort Parameter should have a Max value of 65535" { + (Get-Command $global:function).Parameters['targetPort'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 65535 + } + + It "Supports 'SupportsShouldProcess'" { + Get-Command $global:function | Should -HaveParameter WhatIf + Get-Command $global:function | Should -HaveParameter Confirm + $script:ScriptBlock | Should -Match 'SupportsShouldProcess' + $script:ScriptBlock | Should -Match '\$PSCmdlet\.ShouldProcess\(.+\)' } } - Context "$($file.BaseName)::Function Unit Tests" { - - Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest { - return "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" + Context "Add-ZertoPeerSite::Functional Unit Tests" { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { + return (Get-Content "$global:here\Mocks\TaskId.txt") } - it "Returns a string value" { + It "Returns a string value when no Token Passed" { $results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' - $results | should -Not -BeNullOrEmpty - $results | should -BeOfType "String" - $results | Should -BeExactly "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" + $results | Should -Not -BeNullOrEmpty + $results | Should -BeOfType "String" + $results | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a" } - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest + It "Returns a string value when a Token is passed" { + $results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' -token "NotARealTokenString" + $results | Should -Not -BeNullOrEmpty + $results | Should -BeOfType "String" + $results | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a" + } + + It "Does not return a taskId if '-whatif' is used" { + $results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' -WhatIf + $results | Should -BeNullOrEmpty + } + + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 2 } } - +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Add-ZertoVpgVm.Tests.ps1 b/Tests/Public/Add-ZertoVpgVm.Tests.ps1 new file mode 100644 index 0000000..27af791 --- /dev/null +++ b/Tests/Public/Add-ZertoVpgVm.Tests.ps1 @@ -0,0 +1,53 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -Leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock + } + + Context "$global:function::Parameter Unit Tests" { + + It "$global:function should have exactly 16 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgSettingsIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'Vm'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'VpgName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Supports 'SupportsShouldProcess'" { + Get-Command $global:function | Should -HaveParameter WhatIf + Get-Command $global:function | Should -HaveParameter Confirm + $script:ScriptBlock | Should -Match 'SupportsShouldProcess' + $script:ScriptBlock | Should -Match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + } + + Context "Add-ZertoPeerSite::Functional Unit Tests" { + } +} +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 index f07f347..4fbb862 100644 --- a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 @@ -1,66 +1,63 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { - - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock } Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { - return "3b687246-ac63-40da-9a59-b99863769eb0.928a122b-1763-4664-ad37-cc00bb883f2f" + return (Get-Content "$global:here\Mocks\TaskId.txt") } - Mock -ModuleName ZertoApiWrapper -CommandName get-zertovpg { - return @{vpgIdentifier = "dddf2fa8-79e2-4e4f-a83b-f66676afea64"} + Mock -ModuleName ZertoApiWrapper -CommandName get-zertovpg -ParameterFilter { $VpgName -eq "MyVpg" } { + return (Get-Content "$global:here\Mocks\VPGInfo.json" -Raw | ConvertFrom-Json) } - Context "$($file.BaseName)::Parameter Unit Tests" { - it "Has a parameter for the VpgName that is Mandatory" { - Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory -Type String + Context "$($global:function)::Parameter Unit Tests" { + It "Has a parameter for the VpgName that is Mandatory" { + Get-Command $global:function | Should -HaveParameter vpgName -Mandatory -Type 'String[]' } - it "Has a parameter for the CheckpointName that is Mandatory" { - Get-Command $file.BaseName | Should -HaveParameter CheckpointName -Mandatory -Type String + It "Has a parameter for the CheckpointName that is Mandatory" { + Get-Command $global:function | Should -HaveParameter CheckpointName -Mandatory -Type String } - it "Throws and error when an empty or null checkpointName is specified" { - {Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName ""} | Should -Throw - {Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName $null} | Should -Throw + It "Throws and error when an empty or null checkpointName is specified" { + { Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName "" } | Should -Throw + { Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName $null } | Should -Throw } - it "Throws an error when an empty or null vpgName is specified" { - {Checkpoint-ZertoVpg -vpgName "" -checkpointName "MyCheckPoint"} | Should -Throw - {Checkpoint-ZertoVpg -vpgName $null -checkpointName "MyCheckPoint"} | Should -Throw + It "Throws an error when an empty or null vpgName is specified" { + { Checkpoint-ZertoVpg -vpgName "" -checkpointName "MyCheckPoint" } | Should -Throw + { Checkpoint-ZertoVpg -vpgName $null -checkpointName "MyCheckPoint" } | Should -Throw } - it "Does not support 'SupportsShouldProcess'" { - Get-Command $file.BaseName | Should -Not -HaveParameter WhatIf - Get-Command $file.BaseName | Should -Not -HaveParameter Confirm - $file | Should -Not -FileContentMatch 'SupportsShouldProcess' - $file | Should -Not -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' + It "Does not support 'SupportsShouldProcess'" { + Get-Command $global:function | Should -Not -HaveParameter WhatIf + Get-Command $global:function | Should -Not -HaveParameter Confirm + $script:ScriptBlock | Should -not -match 'SupportsShouldProcess' + $script:ScriptBlock | Should -not -match '\$PSCmdlet\.ShouldProcess\(.+\)' } } - Context "$($file.BaseName)::Function Unit Tests" { + Context "$($global:function)::Function Unit Tests" { - it "should return a not null or empty string" { + It "should return a not null or empty string" { $results = Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName "My Checkpoint Name" - $results | should -not -BeNullOrEmpty - $results | should -BeOfType "String" - $results | should -BeExactly "3b687246-ac63-40da-9a59-b99863769eb0.928a122b-1763-4664-ad37-cc00bb883f2f" + $results | Should -not -BeNullOrEmpty + $results | Should -BeOfType "String" + $results | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a" + } + It "does not return anything when a invalid VPG is defined" { + $results = Checkpoint-ZertoVpg -vpgName "DoesNotExist" -checkpointName "My Checkpoint Name" + $results | Should -Be "Cannot find VPG named DoesNotExist. Please check the name and try again." } - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 2 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg -Exactly 1 } -} \ No newline at end of file +} + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Connect-ZertoAnalytics.Tests.ps1 b/Tests/Public/Connect-ZertoAnalytics.Tests.ps1 new file mode 100644 index 0000000..d91ed80 --- /dev/null +++ b/Tests/Public/Connect-ZertoAnalytics.Tests.ps1 @@ -0,0 +1,72 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock + } + + Context "$($global:function)::Parameter Unit Tests" { + It "Has a parameter for the Required Credentials that is Mandatory" { + Get-Command $global:function | Should -HaveParameter credential -Mandatory -Type PSCredential + } + } + + Context "$($global:function)::Function Unit Tests" { + + InModuleScope -ModuleName ZertoApiWrapper { + Mock -CommandName Invoke-ZARestRequest { + return (Get-Content "$global:here\Mocks\ZAToken.json"-Raw | ConvertFrom-Json) + } + + $password = 'NotARealPassword' | ConvertTo-SecureString -AsPlainText -Force + $cred = New-Object pscredential('NotARealUser', $password) + + $results = Connect-ZertoAnalytics -credential $cred + + It "Creates a Script Level Hashtable Variable for the ZertoAnalytics Headers" { + $script:zaHeaders | Should -BeOfType Hashtable + } + + It "the ZertoAnalytics Headers variable contains 2 items" { + $script:zaHeaders.keys | Should -HaveCount 2 + } + + It "the ZertoAnalytics Headers variable has an 'Accept' key" { + $script:zaHeaders.keys | Should -Contain 'Accept' + } + + It "thh ZertoAnalytics headers variable 'Accept' key should be JSON" { + $script:zaHeaders['Accept'] | Should -match 'application/json' + } + + It "the ZertoAnalytics Headers variable has an 'Authorization' key" { + $script:zaHeaders.keys | Should -Contain 'Authorization' + } + + It "the ZertoAnalytics Headers variable 'Authorization' key should start with 'Bearer'" { + $script:zaHeaders['Authorization'] | Should -Match '^Bearer ' + } + + It "Creates a Script Level Variable for the LastActionTime" { + $script:zaLastActionTime | Should -BeOfType Long + } + + It "LastActionTime Variable should be in the past" { + $script:zaLastActionTime | Should -BeLessThan (Get-Date).Ticks + } + + It "Returns Header Information" { + $results | Should -not -BeNullOrEmpty + $results['Authorization'] | Should -MatchExactly 'Bearer N074r34l70k3n' + $results['Accept'] | Should -Match 'application/json' + } + } + + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZARestRequest -Exactly 1 + } +} + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index 59c5e8b..802cc9b 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -1,203 +1,142 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force -$userName = "zerto\build" -$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force -$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password) -$Server = "192.168.1.100" -$zertoPort = "7669" +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -Leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag Unit { - - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock } - Context "$($file.BaseName)::Parameter Unit Tests" { + Context "$($global:function)::Parameter Unit Tests" { - it "server vairable has a mandatory String parameter" { - Get-Command $file.BaseName | Should -HaveParameter zertoserver -Mandatory -Type String + It "server vairable has a mandatory String parameter" { + Get-Command $global:function | Should -HaveParameter zertoserver -Mandatory -Type String } - it "server variable does not accecpt an empty or null input" { - {Connect-ZertoServer -zertoServer $null -credential $credential} | Should -Throw - {Connect-ZertoServer -zertoServer "" -credential $credential} | Should -Throw + It "server variable does not accecpt an empty or null input" { + { Connect-ZertoServer -zertoServer $null -credential $credential } | Should -Throw + { Connect-ZertoServer -zertoServer "" -credential $credential } | Should -Throw } - it "port variable has a non-mandatory String parameter" { - Get-Command $file.BaseName | Should -HaveParameter zertoPort -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter zertoPort -Type String - Get-Command $file.BaseName | Should -HaveParameter zertoPort -DefaultValue "9669" + It "port variable has a non-mandatory String parameter" { + Get-Command $global:function | Should -HaveParameter zertoPort -Not -Mandatory + Get-Command $global:function | Should -HaveParameter zertoPort -Type String + Get-Command $global:function | Should -HaveParameter zertoPort -DefaultValue "9669" } - it "port variable does not accecpt an empty or null input" { - {Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "" -credential $credential} | Should -Throw - {Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort $null -credential $credential} | Should -Throw + It "port variable does not accecpt an empty or null input" { + { Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "" -credential $credential } | Should -Throw + { Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort $null -credential $credential } | Should -Throw } - it "port variable should fall between 1024 and 65535" { - {Connect-ZertoServer -zertoServer $Server -zertoPort 1023 -credential $credential} | Should -Throw - {Connect-ZertoServer -zertoServer $Server -zertoPort 65536 -credential $credential} | Should -Throw - {Connect-ZertoServer -zertoServer $Server -zertoPort 0 -credential $credential} | Should -Throw - {Connect-ZertoServer -zertoServer $Server -zertoPort -1 -credential $credential} | Should -Throw + It "port variable should fall between 1024 and 65535" { + { Connect-ZertoServer -zertoServer $Server -zertoPort 1023 -credential $credential } | Should -Throw + { Connect-ZertoServer -zertoServer $Server -zertoPort 65536 -credential $credential } | Should -Throw + { Connect-ZertoServer -zertoServer $Server -zertoPort 0 -credential $credential } | Should -Throw + { Connect-ZertoServer -zertoServer $Server -zertoPort -1 -credential $credential } | Should -Throw } - it "has a mandatory PSCredential parameter for the credential vairable" { - Get-Command $file.BaseName | Should -HaveParameter credential -Mandatory -Type PSCredential + It "has a mandatory PSCredential parameter for the credential vairable" { + Get-Command $global:function | Should -HaveParameter credential -Mandatory -Type PSCredential } - it "should require a PSCredentialObject for the credentials" { - {Connect-ZertoServer -zertoServer -credential "MyUsername"} | Should -Throw - {Connect-ZertoServer -zertoServer -credential 1234} | Should -Throw - {Connect-ZertoServer -zertoServer -credential $(@{Username = "zerto\build"; Password = 'SecureString'})} | Should -Throw + It "should require a PSCredentialObject for the credentials" { + { Connect-ZertoServer -zertoServer -credential "MyUsername" } | Should -Throw + { 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 ZertoApiWrapper { - Context "$($file.BaseName)::InModuleScope Function Unit Tests" { + InModuleScope -ModuleName ZertoApiWrapper { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { + # Attempted to Mock this per the Mock Below and it blew up. Auth Headers Returns a Dictionary + # and does not index the same way when imported from a JSON file. Need addtional investigation. + $xZertoSession = @("e34da0b0-4bc2-4cda-b316-0384e35bdca5") + $Headers = @{'x-zerto-session' = $xZertoSession } + $results = @{'Headers' = $Headers } + return $results + } - $server = '192.168.1.100' - $userName = "zerto\build" - $password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force - $credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password) + Context "$($global:function)::InModuleScope Function Unit Tests" { - - Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { - $xZertoSession = @("7ecf544d-e7ed-4108-86f3-fb355c51cdfa") - $Headers = @{'x-zerto-session' = $xZertoSession} - $results = @{'Headers' = $Headers} - return $results + BeforeAll { + $server = '192.168.1.100' + $password = ConvertTo-SecureString -String "NotARealPassword" -AsPlainText -Force + $credential = New-Object pscredential('NotARealUser', $password) + $now = $(Get-Date).ticks + Connect-ZertoServer -zertoServer $server -credential $credential } - Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite { - $results = @{ - BandwidthThrottlingInMBs = -1 - ContactEmail = "vSphere-Site01@zerto.com" - ContactName = "vSphere-Site01@zerto.com" - ContactPhone = "066-6666666" - IpAddress = "192.168.200.1" - IsReplicationToSelfEnabled = $True - Link = @{ - href = "https://192.168.24.1:7669/v1/localsite" - identifier = "928a122b-1763-4664-ad37-cc00bb883f2f" - rel = $null - type = "LocalSiteApi" - } - Location = "vSphere-Site01" - SiteName = "vSphere-Site01 at Zerto" - SiteType = "VCenter" - UtcOffsetInMinutes = -240 - Version = "7.0.0" - SiteIdentifier = "928a122b-1763-4664-ad37-cc00bb883f2f" - } - return $results - } - - $now = $(Get-Date).ticks - Connect-ZertoServer -zertoServer $server -credential $credential - - it "Module Scope zvmServer variable tests" { + It "Module Scope zvmServer variable tests" { $script:zvmServer | Should -Not -BeNullOrEmpty $script:zvmServer | Should -Be $server } - it "Module Scope zvmPort variable tests" { + It "Module Scope zvmPort variable tests" { $script:zvmPort | Should -Not -BeNullOrEmpty $script:zvmPort | Should -Be '9669' } - it "Module Scope zvmLastAction variable tests" { + It "Module Scope zvmLastAction variable tests" { $script:zvmLastAction | Should -Not -BeNullOrEmpty $script:zvmLastAction | Should -BeGreaterOrEqual $now } - it "Module Scope zvmHeaders variable tests" { + It "Module Scope zvmHeaders variable tests" { $script:zvmHeaders | Should -Not -BeNullOrEmpty - $script:zvmHeaders | Should -BeOfType Hashtable - $script:zvmHeaders.keys.count | Should -BeExactly 2 + $script:zvmHeaders | Should -BeOfType PSCustomObject + $script:zvmHeaders.keys.count | Should -BeExactly 3 $script:zvmHeaders.ContainsKey('x-zerto-session') | Should -BeTrue $script:zvmHeaders.ContainsKey('Accept') | Should -BeTrue $script:zvmHeaders['x-zerto-session'] | Should -BeOfType String $script:zvmHeaders['Accept'] | Should -BeOfType String } - it "Module Scope zvmLocalInfo variable tests" { - $script:zvmLocalInfo | Should -Not -BeNullOrEmpty - $script:zvmLocalInfo | Should -BeOfType Hashtable - $script:zvmLocalInfo['SiteIdentifier'] | Should -BeOfType String - $script:zvmLocalInfo.ContainsKey('SiteIdentifier') | Should -BeTrue - $script:zvmLocalInfo['SiteIdentifier'] | Should -BeOfType String - } - $headers = Connect-ZertoServer -zertoServer $Server -credential $credential -returnHeaders - it "returns a Hashtable with 2 keys" { + It "returns a Hashtable with 2 keys" { $headers | Should -BeOfType Hashtable - $headers.keys.count | should be 2 + $headers.keys.count | Should -Be 3 } - it "return value has a key called 'x-zerto-session'" { - $headers.ContainsKey('x-zerto-session') | should be $true + It "return value has a key called 'x-zerto-session'" { + $headers.ContainsKey('x-zerto-session') | Should -Be $true } - it "return key 'x-zerto-session' value should be a string" { - $headers['x-zerto-session'] | should -BeOfType "String" - $headers['x-zerto-session'] | Should -BeExactly "7ecf544d-e7ed-4108-86f3-fb355c51cdfa" + It "return key 'x-zerto-session' value should be a string" { + $headers['x-zerto-session'] | Should -BeOfType "String" + $headers['x-zerto-session'] | Should -BeExactly "e34da0b0-4bc2-4cda-b316-0384e35bdca5" } - it "return value has a key called 'accept'" { - $headers.ContainsKey('accept') | should be $true + It "return value has a key called 'accept'" { + $headers.ContainsKey('accept') | Should -Be $true } - it "return key 'accept' value should be 'application/json'" { - $headers['accept'] | should be 'application/json' + It "return key 'accept' value should be 'application/json'" { + $headers['accept'] | Should -Be 'application/json' } - it "should not require a port to be specified" { + It "should not require a port to be specified" { Connect-ZertoServer -zertoServer $Server -credential $credential } - it "returns null when -ReturnHeaders is not used" { + It "returns null when -ReturnHeaders is not used" { Connect-ZertoServer -zertoServer $Server -credential $credential | Should -BeNullOrEmpty } - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 4 } } } -<# -Describe "Connect-ZertoServer" -Tag Integration { - it "file should exist" { - "$filePath\$fileName" | should exist - } - it "has a function called Connect-ZertoServer" { - get-command Connect-ZertoServer | should be $true - } - $headers = Connect-ZertoServer -zertoServer $Server -zertoPort $zertoPort -credential $credential -returnHeaders - it "returns a Hashtable with 2 keys" { - $headers.keys.count | should be 2 - } - it "return value has a key called 'x-zerto-session'" { - $headers.ContainsKey('x-zerto-session') | should be $true - } - it "return key 'x-zerto-session' value should be a string" { - $headers['x-zerto-session'].gettype().name | should be "String" - } - it "return value has a key called 'accept'" { - $headers.ContainsKey('accept') | should be $true - } - it "return key 'accept' value should be 'application/json'" { - $headers['accept'] | should be 'application/json' - } - Disconnect-ZertoServer -} - #> + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Copy-ZertoVpg.Tests.ps1 b/Tests/Public/Copy-ZertoVpg.Tests.ps1 new file mode 100644 index 0000000..6f0c629 --- /dev/null +++ b/Tests/Public/Copy-ZertoVpg.Tests.ps1 @@ -0,0 +1,127 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock + } + + Context "$($global:function)::Parameter Unit Tests" { + + It "$global:function should have exactly 16 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 + } + + $ParameterTestCases = @( + @{ParameterName = 'SourceVpgName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'NewVpgName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'VMs'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + } + } + + It "Supports 'SupportsShouldProcess'" { + Get-Command $global:function | Should -HaveParameter WhatIf + Get-Command $global:function | Should -HaveParameter Confirm + $script:ScriptBlock | Should -match 'SupportsShouldProcess' + $script:ScriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + } + + Context "$($global:function)::Function Unit Tests" { + Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg -ParameterFilter { + $vpgName -eq "MyVpg" + } { + return (Get-Content "$global:here\Mocks\GetVpg.json" -Raw | ConvertFrom-Json) + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg -ParameterFilter { + $vpgName -eq "NotAVpg" + } { + return $null + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoUnprotectedVm { + return (Get-Content "$global:here\Mocks\UnprotectedVms.json" -Raw | ConvertFrom-Json) + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoProtectedVm { + return (Get-Content "$global:here\Mocks\ProtectedVms.json" -Raw | ConvertFrom-Json) + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq "vpgSettings/copyVpgSettings" + } { + return (Get-Content "$global:here\Mocks\VpgId.txt") + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq "vpgSettings/9607f923-00a7-477b-8b04-26a386214455/vms" + } { + return $null + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq "vpgSettings/9607f923-00a7-477b-8b04-26a386214455" + } { + return (Get-Content "$global:here\Mocks\CopyVpgSettings.json" -Raw | ConvertFrom-Json) + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Save-ZertoVpgSetting { + return (Get-Content "$global:here\Mocks\TaskId.txt") + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Get-Map -ParameterFilter { + $null -ne $InputObject[0].VpgName + } { + @{ + "WindowsBox" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-90" + "CentOS-Test" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-88" + "Application01" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-35" + "sql01-test" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-73" + "jenkins" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-75" + } + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Get-Map -ParameterFilter { + $null -eq $InputObject[0].VpgName + } { + @{ + "Win2019Template" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-79" + "Ubuntu01" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-34" + "WinTemplate" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-25" + "sql01-prod" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-87" + "nczvm.nc.lab" = "d809de8e-deb7-45cc-b620-08030a1143e1.vm-30" + } + } -Verifiable + + It "Should throw an error when no VPG is found" { + { Copy-ZertoVpg -SourceVpgName "NotAVpg" -NewVpgName "NewVpg" -VMs 'sql01-prod', 'Ubuntu01' } | Should Throw "Unable to find a VPG with the name:" + } + + It "Returns a TaskIdentifier when called correctly" { + Copy-ZertoVpg -SourceVpgName "MyVpg" -NewVpgName "NewVpg" -VMs 'sql01-prod', 'Ubuntu01' | Should -Be "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a" + } + + It "Should warn when VM is not found" { + $results = Copy-ZertoVpg -SourceVpgName "MyVpg" -NewVpgName "NewVpg" -VMs 'sql01-prod', 'Ubuntu01', 'DoesNotExist' 3>&1 + $results[0].ToString() | Should -Match 'Unable to find VM with Name DoesNotExist. Skipping.' + + } + + Assert-VerifiableMock + } +} + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Disconnect-ZertoServer.Tests.ps1 b/Tests/Public/Disconnect-ZertoServer.Tests.ps1 index 5be178d..51e5f2c 100644 --- a/Tests/Public/Disconnect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Disconnect-ZertoServer.Tests.ps1 @@ -1,37 +1,40 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { - Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { - $null - } - Mock -ModuleName ZertoApiWrapper -CommandName Remove-Variable { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - } - - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 - } - - Context "$($file.BaseName)::Parameter Unit Tests" { - it "Does not take any parameters" { - (get-command disconnect-zertoserver).parameters.count | Should -BeExactly 11 + Context "$($global:function)::Parameter Unit Tests" { + It "Does not take any parameters" { + (Get-Command disconnect-zertoserver).parameters.count | Should -BeExactly 11 } } - Context "$($file.BaseName)::Function Unit Tests" { - it "Does not return anything" { - Disconnect-ZertoServer | Should -BeNullOrEmpty + Context "$($global:function)::Function Unit Tests" { + InModuleScope -ModuleName ZertoApiWrapper { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { + # Attempted to Mock this per the Mock Below and it blew up. Auth Headers Returns a Dictionary + # and does not index the same way when imported from a JSON file. Need addtional investigation. + $xZertoSession = @("e34da0b0-4bc2-4cda-b316-0384e35bdca5") + $Headers = @{'x-zerto-session' = $xZertoSession } + $results = @{'Headers' = $Headers } + return $results + } + + Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite { + return (Get-Content -Path "$global:here\Mocks\LocalSiteInfo.json" -Raw | ConvertFrom-Json) + } + + BeforeAll { + Connect-ZertoServer + } + + It "Does not return anything" { + Disconnect-ZertoServer | Should -BeNullOrEmpty + } } } } + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Edit-ZertoVra.Tests.ps1 b/Tests/Public/Edit-ZertoVra.Tests.ps1 index 4026b3d..6e8de1e 100644 --- a/Tests/Public/Edit-ZertoVra.Tests.ps1 +++ b/Tests/Public/Edit-ZertoVra.Tests.ps1 @@ -1,187 +1,103 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path) -Replace "Tests", "ZertoApiWrapper" -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest { - return "8dcfdc8e-e5d2-4ba4-9885-f9eb57d92b14.928a122b-1763-4664-ad37-cc00bb883f2f" + Get-Content $global:here\Mocks\TaskId.txt } - Mock -ModuleName ZertoApiWrapper Get-ZertoVra { - $vraInformation = @{ - DatastoreClusterIdentifier = $null - DatastoreClusterName = $null - DatastoreIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.Prod_Datastore" - DatastoreName = "Prod_Datastore" - HostIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.znest82esxus-1" - HostVersion = 6.5 - IpAddress = 192.168.1.100 - Link = @{ - href = "https://192.168.1.200:7669/v1/vras/2609816293328110468" - identifier = "269816293328110468" - rel = $null - type = "VraApi" - } - MemoryInGB = 3 - NetworkIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.network-1" - NetworkName = "Test Network" - Progress = 0 - ProtectedCounters = @{ - Vms = 0 - Volumes = 0 - Vpgs = 0 - } - RecoveryCounters = @{ - Vms = 0 - Volumes = 0 - Vpgs = 0 - } - SelfProtectedVpgs = 0 - Status = 0 - VraAlerts = @{ - VraAlertStatus = 0 - } - VraGroup = "default_group" - VraIdentifier = 269816293328110468 - VraIdentifierStr = "269816293328110468" - VraName = "VRA-znest82esxus-1" - VraNetworkDataApi = @{ - DefaultGateway = "192.168.1.1" - SubnetMask = "255.255.255.0" - VraIpAddress = "192.168.1.100" - VraIpConfigurationTypeApi = "Dhcp" - } - VraVersion = 7.0 - } - return $vraInformation + Mock -ModuleName ZertoApiWrapper Get-ZertoVra -ParameterFilter { $vraIdentifier -in @("MyVraIdentifier", "PasswordVraIdentifier") } { + Get-Content $global:here\Mocks\GetSingleVra.json -Raw | ConvertFrom-Json } - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Mock -ModuleName ZertoApiWrapper Get-ZertoVra -ParameterFilter { $vraIdentifier -eq "DoesNotExist" } { + $null } - Context "$($File.BaseName)::Parameter Unit Tests" { + Mock -ModuleName ZertoApiWrapper Get-ZertoVra -ParameterFilter { $vraIdentifier -eq "DhcpVraIdentifier" } { + Get-Content $global:here\Mocks\GetDhcpVra.json -Raw | ConvertFrom-Json + } - It "has a mandatory String variable for the vraIdentifier" { - Get-Command $file.BaseName | Should -HaveParameter vraIdentifier -Mandatory -Type String - {Edit-ZertoVra} + Context "$($global:function)::Parameter Unit Tests" { + + $ParameterTestCases = @( + @{ParameterName = 'vraIdentifier'; Type = 'String'; Mandatory = $true } + @{ParameterName = 'groupName'; Type = 'String'; Mandatory = $false } + @{ParameterName = 'vraIpAddress'; Type = 'String'; Mandatory = $false } + @{ParameterName = 'defaultGateway'; Type = 'String'; Mandatory = $false } + @{ParameterName = 'subnetMask'; Type = 'String'; Mandatory = $false } + @{ParameterName = 'HostRootPassword'; Type = 'securestring'; Mandatory = $false } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type } - It "has a non-mandatory String variable for the Bandwidth Group" { - Get-Command $file.BaseName | Should -HaveParameter groupName -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter groupName -Type String + $StringTestCases = @( + @{ ParameterName = 'vraIdentifier' } + @{ ParameterName = 'groupName' } + ) + + It " validates against null or empty values" -TestCases $StringTestCases { + param($ParameterName) + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 } - it "has a non-mandatory String variable for the staticIp Address" { - Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Type String + $IpAddrTestCases = @( + @{ParameterName = 'vraIpAddress' } + @{ParameterName = 'defaultGateway' } + @{ParameterName = 'subnetMask' } + ) + + It " validates string for a valid IP Address" -TestCases $IpAddrTestCases { + param($ParameterName) + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateScript] }.Count | Should -Be 1 + $attrs.Where{ $_ -is [ValidateScript] }.ScriptBlock | Should -Match '\$_ \-match \[IPAddress\]\$_' } - it "has a non-mandatory String variable for the default gateway" { - Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Type String - } - - it "has a non-mandatory String variable for the subnetmask" { - Get-Command $file.BaseName | Should -HaveParameter subnetMask -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter subnetMask -Type String - } - - it "supports WhatIf" { - Get-Command $file.BaseName | Should -HaveParameter WhatIf -Not -Mandatory - } - - $cases = ` - @{vraIpAddress = "192.168.1.256"}, ` - @{vraIpAddress = "192.168.1"}, ` - @{vraIpAddress = "String"}, ` - @{vraIpAddress = 192.168.1}, ` - @{vraIpAddress = 192.168.1.246}, ` - @{vraIpAddress = 32}, ` - @{vraIpAddress = ""}, ` - @{vraIpAddress = $null} - It "IpAddress field require valid IP addresses as a String" -TestCases $cases { - param ( $vraIpAddress ) - {Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -vraIpaddress $vraIpAddress} | Should -Throw - } - - $cases = ` - @{subnetMask = "192.168.1.256"}, ` - @{subnetMask = "192.168.1"}, ` - @{subnetMask = "String"}, ` - @{subnetMask = 192.168.1}, ` - @{subnetMask = 192.168.1.246}, ` - @{subnetMask = 32}, ` - @{subnetMask = ""}, ` - @{subnetMask = $null} - It "subnetMask field require valid IP addresses as a String" -TestCases $cases { - param ( $vraIpAddress ) - {Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -subnetMask $subnetMask} | Should -Throw - } - - $cases = ` - @{defaultGateway = "192.168.1.256"}, ` - @{defaultGateway = "192.168.1"}, ` - @{defaultGateway = "String"}, ` - @{defaultGateway = 192.168.1}, ` - @{defaultGateway = 192.168.1.246}, ` - @{defaultGateway = 32}, ` - @{defaultGateway = ""}, ` - @{defaultGateway = $null} - It "defaultGateway field require valid IP addresses as a String" -TestCases $cases { - param ( $vraIpAddress ) - {Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -defaultGateway $defaultGateway} | Should -Throw - } - - $cases = ` - @{vraIdentifier = ""; paramName = "vraIdentifier"; paramValue = ""}, ` - @{vraIdentifier = $null; paramName = "vraIdentifier"; paramValue = ""}, ` - @{vraIdentifier = "MyVraIdentifier"; paramName = "groupName"; paramValue = ""}, ` - @{vraIdentifier = "MyVraIdentifier"; paramName = "groupName"; paramValue = $null}, ` - @{vraIdentifier = "MyVraIdentifier"; paramName = "vraIpAddress"; paramValue = ""}, ` - @{vraIdentifier = "MyVraIdentifier"; paramName = "vraIpAddress"; paramValue = $null}, ` - @{vraIdentifier = "MyVraIdentifier"; paramName = "subnetMask"; paramValue = ""}, ` - @{vraIdentifier = "MyVraIdentifier"; paramName = "subnetMask"; paramValue = $null}, ` - @{vraIdentifier = "MyVraIdentifier"; paramName = "defaultGateway"; paramValue = ""}, ` - @{vraIdentifier = "MyVraIdentifier"; paramName = "defaultGateway"; paramValue = $null} - - It " does not take empty or null" -TestCases $cases { - param($vraIdentifier, $paramValue, $paramName ) - if ([String]::IsNullOrEmpty($vraIdentifier)) { - {Edit-ZertoVra -vraIdentifier $vraIdentifier} | Should -Throw - } else { - {Edit-ZertoVra -vraIdentifier $vraIdentifier -$paramName $paramValue} | should -Throw - } + It "Supports 'SupportsShouldProcess'" { + Get-Command $global:function | Should -HaveParameter WhatIf + Get-Command $global:function | Should -HaveParameter Confirm + (Get-Command $global:function).ScriptBlock | Should -Match 'SupportsShouldProcess' + (Get-Command $global:function).ScriptBlock | Should -Match '\$PSCmdlet\.ShouldProcess\(.+\)' } } - Context "$($File.BaseName)::Function Unit Tests" { + Context "$($global:function)::Function Unit Tests" { - It "Returns a string" { + It "Returns a task id string" { $results = Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -groupName "MyGroup" - $results | should not benullorempty - $results | should -BeOfType "String" - $results | Should -BeExactly "8dcfdc8e-e5d2-4ba4-9885-f9eb57d92b14.928a122b-1763-4664-ad37-cc00bb883f2f" + $results | Should not benullorempty + $results | Should -BeOfType "String" + $results | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a" } - it "Supports 'SupportsShouldProcess'" { - Get-Command $file.BaseName | Should -HaveParameter WhatIf - Get-Command $file.BaseName | Should -HaveParameter Confirm - $file | Should -FileContentMatch 'SupportsShouldProcess' - $file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' + It "Throws an error when the VPG does not exist" { + { Edit-ZertoVra -vraIdentifier "DoesNotExist" -groupName "MyNewGroup" } | Should Throw "VRA with Identifier:" + } + + It "Runs when passed static IP information" { + Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -vraIpAddress "192.168.1.250" -defaultGateway "192.168.1.254" -subnetMask "255.255.255.0" + } + + It "Processes a VRA with a DHCP address" { + Edit-ZertoVra -vraIdentifier "DhcpVraIdentifier" -groupName "MyNewGroup" | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a" + } + + It "Runs with root password provided" { + $SecurePassword = 'NotARealPassword' | ConvertTo-SecureString -AsPlainText -Force + Edit-ZertoVra -vraIdentifier "PasswordVraIdentifier" -HostRootPassword $SecurePassword | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a" } } - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVra -} \ No newline at end of file + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 4 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVra -Exactly 5 +} + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Export-ZertoVmNicSetting.Tests.ps1 b/Tests/Public/Export-ZertoVmNicSetting.Tests.ps1 new file mode 100644 index 0000000..f7ecbb1 --- /dev/null +++ b/Tests/Public/Export-ZertoVmNicSetting.Tests.ps1 @@ -0,0 +1,32 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + + $ParameterTestCases = @( + @{ParameterName = 'OutputFile'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " has validation set" -TestCases $ParameterTestCases { + param($ParameterName) + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + } + + Context "$global:function::Function Unit Tests" { + + } +} + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 index e46b59e..0e5ec77 100644 --- a/Tests/Public/Export-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Export-ZertoVpg.Tests.ps1 @@ -1,53 +1,39 @@ #Requires -Modules Pester -#Region - Test Setup -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force -#EndRegion +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 - } + Context "$global:function::Parameter Unit Tests" { - Context "$($file.BaseName)::Parameter Unit Tests" { - it "has a mantatory string parameter for the output path" { - Get-Command $file.BaseName | Should -HaveParameter outputPath -Type String -Mandatory + $ParameterTestCases = @( + @{ParameterName = 'OutputPath'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'allVpgs'; Type = 'Switch'; Mandatory = $true; Validation = $null } + ) + + It " parameter is of type, with correct validation" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type } - it "has a non-mandatory string array parameter for vpgName(s) to export" { - Get-Command $file.BaseName | Should -HaveParameter vpgName -Type String[] -Mandatory - } + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } - it "has a non-mandatory switch parameter to export all vpgs" { - Get-Command $file.BaseName | Should -HaveParameter allVpgs -Type Switch -Mandatory - } - - it "No defined vpgName or AllVpg switch should throw an error" { - {Export-ZertoVpg -outputPath "."} | Should -Throw - } - - it "Output path does not take null or empty string" { - {Export-ZertoVpg -outputPath "" -allVpgs} | Should -Throw - {Export-ZertoVpg -outputPath $null -allVpgs} | Should -Throw - } - - it "Vpg Name parameter does not take null or empty string" { - {Export-ZertoVpg -outputPath "." -vpgName = ""} | Should -Throw - {Export-ZertoVpg -outputPath "." -vpgName = $null} | Should -Throw + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + } } } - Context "$($file.BaseName)::Function Unit Tests" { + Context "$($global:function)::Function Unit Tests" { Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg { $returnObj = @{ VpgName = "HRIS" @@ -60,6 +46,10 @@ Describe $file.BaseName -Tag 'Unit' { return "1024d377-afb8-4880-82f0-96eeff413ffd" } + Mock -ModuleName ZertoApiWrapper -CommandName Remove-ZertoVpgSettingsIdentifier { + return $null + } + Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpgSetting { $returnObj = @{ Backup = $null @@ -213,11 +203,11 @@ Describe $file.BaseName -Tag 'Unit' { $outputPath = "TestDrive:" - it "Output path should exist" { + It "Output path should exist" { $outputPath | Should -Exist } - it "Exported JSON file should exist after function called" { + It "Exported JSON file should exist after function called" { $vpgName = "HRIS" Export-ZertoVpg -outputPath $outputPath -vpgName $vpgName $outputFile = "{0}\{1}.json" -f $outputPath, $vpgName @@ -225,11 +215,11 @@ Describe $file.BaseName -Tag 'Unit' { $outputFile | Should -Not -BeNullOrEmpty } - it "Only one file should be present in the TestDrive" { + It "Only one file should be present in the TestDrive" { (Get-ChildItem $outputPath).Count | Should -BeExactly 1 } - it "Should be valid JSON" { + It "Should be valid JSON" { $vpgName = "HRIS" Export-ZertoVpg -outputPath $outputPath -vpgName $vpgName $outputFile = "{0}\{1}.json" -f $outputPath, $vpgName @@ -247,3 +237,6 @@ Describe $file.BaseName -Tag 'Unit' { Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpgSetting } } + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Get-ZAAlert.Tests.ps1 b/Tests/Public/Get-ZAAlert.Tests.ps1 new file mode 100644 index 0000000..1a4cd6d --- /dev/null +++ b/Tests/Public/Get-ZAAlert.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'limitTo'; Type = 'int'; Mandatory = $false; Validation = 'Range' } + @{ParameterName = 'alertIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "LimitTo Parameter should have a Min value of 1" { + (Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 1 + } + + It "LimitTo Parameter should have a Max value of 1000000" { + (Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 1000000 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZADatastore.Tests.ps1 b/Tests/Public/Get-ZADatastore.Tests.ps1 new file mode 100644 index 0000000..8cc0132 --- /dev/null +++ b/Tests/Public/Get-ZADatastore.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'datastoreIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'clusterIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAEvent.Tests.ps1 b/Tests/Public/Get-ZAEvent.Tests.ps1 new file mode 100644 index 0000000..61bcfd8 --- /dev/null +++ b/Tests/Public/Get-ZAEvent.Tests.ps1 @@ -0,0 +1,77 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + + It "$global:function should have exactly 16 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 + } + + $ParameterTestCases = @( + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'limitTo'; Type = 'int'; Mandatory = $false; Validation = 'Range' } + @{ParameterName = 'category'; Type = 'String'; Mandatory = $false; Validation = 'Set' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + 'Set' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "LimitTo Parameter should have a Min value of 1" { + (Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 1 + } + + It "LimitTo Parameter should have a Max value of 1000000" { + (Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 1000000 + } + + It "Category parameter should only have 2 options" { + (Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues.Count | Should -Be 2 + } + + It "Category parameter should take 'events'" { + (Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'events' + } + + It "Category parameter should take 'alertsHistory'" { + (Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'alertsHistory' + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalAverageHistory.Tests.ps1 b/Tests/Public/Get-ZAJournalAverageHistory.Tests.ps1 new file mode 100644 index 0000000..4ab1f59 --- /dev/null +++ b/Tests/Public/Get-ZAJournalAverageHistory.Tests.ps1 @@ -0,0 +1,59 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalAverageSize.Tests.ps1 b/Tests/Public/Get-ZAJournalAverageSize.Tests.ps1 new file mode 100644 index 0000000..4ab0358 --- /dev/null +++ b/Tests/Public/Get-ZAJournalAverageSize.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalBreach.Tests.ps1 b/Tests/Public/Get-ZAJournalBreach.Tests.ps1 new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/Tests/Public/Get-ZAJournalBreach.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalHistoryStat.Tests.ps1 b/Tests/Public/Get-ZAJournalHistoryStat.Tests.ps1 new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/Tests/Public/Get-ZAJournalHistoryStat.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalSiteAverageHistory.Tests.ps1 b/Tests/Public/Get-ZAJournalSiteAverageHistory.Tests.ps1 new file mode 100644 index 0000000..b91ec04 --- /dev/null +++ b/Tests/Public/Get-ZAJournalSiteAverageHistory.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalSiteAverageSize.Tests.ps1 b/Tests/Public/Get-ZAJournalSiteAverageSize.Tests.ps1 new file mode 100644 index 0000000..b91ec04 --- /dev/null +++ b/Tests/Public/Get-ZAJournalSiteAverageSize.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalSiteHistoryStat.Tests.ps1 b/Tests/Public/Get-ZAJournalSiteHistoryStat.Tests.ps1 new file mode 100644 index 0000000..b91ec04 --- /dev/null +++ b/Tests/Public/Get-ZAJournalSiteHistoryStat.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalSiteHistorySummary.Tests.ps1 b/Tests/Public/Get-ZAJournalSiteHistorySummary.Tests.ps1 new file mode 100644 index 0000000..b91ec04 --- /dev/null +++ b/Tests/Public/Get-ZAJournalSiteHistorySummary.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalSiteSizeStat.Tests.ps1 b/Tests/Public/Get-ZAJournalSiteSizeStat.Tests.ps1 new file mode 100644 index 0000000..b91ec04 --- /dev/null +++ b/Tests/Public/Get-ZAJournalSiteSizeStat.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalStatusProportion.Tests.ps1 b/Tests/Public/Get-ZAJournalStatusProportion.Tests.ps1 new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/Tests/Public/Get-ZAJournalStatusProportion.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalStorageStat.Tests.ps1 b/Tests/Public/Get-ZAJournalStorageStat.Tests.ps1 new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/Tests/Public/Get-ZAJournalStorageStat.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAJournalSummary.Tests.ps1 b/Tests/Public/Get-ZAJournalSummary.Tests.ps1 new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/Tests/Public/Get-ZAJournalSummary.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZALicense.Tests.ps1 b/Tests/Public/Get-ZALicense.Tests.ps1 new file mode 100644 index 0000000..e3e16ee --- /dev/null +++ b/Tests/Public/Get-ZALicense.Tests.ps1 @@ -0,0 +1,19 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 11 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 11 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAMonitoring.Tests.ps1 b/Tests/Public/Get-ZAMonitoring.Tests.ps1 new file mode 100644 index 0000000..1ced87b --- /dev/null +++ b/Tests/Public/Get-ZAMonitoring.Tests.ps1 @@ -0,0 +1,24 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 12 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 12 + } + + It "$global:function has a non-mandatory string parameter for the zOrgIdentifier" { + Get-Command $global:function | Should -HaveParameter zOrgIdentifier -Type String + Get-Command $global:function | Should -HaveParameter zOrgIdentifier -not -Mandatory + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZANetworkSiteAverageIOPS.Tests.ps1 b/Tests/Public/Get-ZANetworkSiteAverageIOPS.Tests.ps1 new file mode 100644 index 0000000..be1237c --- /dev/null +++ b/Tests/Public/Get-ZANetworkSiteAverageIOPS.Tests.ps1 @@ -0,0 +1,60 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 17 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 17 + } + + $ParameterTestCases = @( + @{ParameterName = 'protectedSiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZANetworkSiteAveragePerformance.Tests.ps1 b/Tests/Public/Get-ZANetworkSiteAveragePerformance.Tests.ps1 new file mode 100644 index 0000000..be1237c --- /dev/null +++ b/Tests/Public/Get-ZANetworkSiteAveragePerformance.Tests.ps1 @@ -0,0 +1,60 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 17 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 17 + } + + $ParameterTestCases = @( + @{ParameterName = 'protectedSiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZANetworkSiteStat.Tests.ps1 b/Tests/Public/Get-ZANetworkSiteStat.Tests.ps1 new file mode 100644 index 0000000..0d7b26a --- /dev/null +++ b/Tests/Public/Get-ZANetworkSiteStat.Tests.ps1 @@ -0,0 +1,51 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 16 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 + } + + $ParameterTestCases = @( + @{ParameterName = 'protectedSiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZANetworkSiteSummary.Tests.ps1 b/Tests/Public/Get-ZANetworkSiteSummary.Tests.ps1 new file mode 100644 index 0000000..0d7b26a --- /dev/null +++ b/Tests/Public/Get-ZANetworkSiteSummary.Tests.ps1 @@ -0,0 +1,51 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 16 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 + } + + $ParameterTestCases = @( + @{ParameterName = 'protectedSiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZANetworkVpgAverageIOPS.Tests.ps1 b/Tests/Public/Get-ZANetworkVpgAverageIOPS.Tests.ps1 new file mode 100644 index 0000000..4ab0358 --- /dev/null +++ b/Tests/Public/Get-ZANetworkVpgAverageIOPS.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZANetworkVpgAveragePerformance.Tests.ps1 b/Tests/Public/Get-ZANetworkVpgAveragePerformance.Tests.ps1 new file mode 100644 index 0000000..4ab0358 --- /dev/null +++ b/Tests/Public/Get-ZANetworkVpgAveragePerformance.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZANetworkVpgStat.Tests.ps1 b/Tests/Public/Get-ZANetworkVpgStat.Tests.ps1 new file mode 100644 index 0000000..e2ece1b --- /dev/null +++ b/Tests/Public/Get-ZANetworkVpgStat.Tests.ps1 @@ -0,0 +1,49 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZANetworkVpgSummary.Tests.ps1 b/Tests/Public/Get-ZANetworkVpgSummary.Tests.ps1 new file mode 100644 index 0000000..e2ece1b --- /dev/null +++ b/Tests/Public/Get-ZANetworkVpgSummary.Tests.ps1 @@ -0,0 +1,49 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAPlannerJournalSizeReport.Tests.ps1 b/Tests/Public/Get-ZAPlannerJournalSizeReport.Tests.ps1 new file mode 100644 index 0000000..f6b7536 --- /dev/null +++ b/Tests/Public/Get-ZAPlannerJournalSizeReport.Tests.ps1 @@ -0,0 +1,57 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 17 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 17 + } + + $ParameterTestCases = @( + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vmIdentifier'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'recoveryType'; Type = 'String'; Mandatory = $true; Validation = 'Set' } + @{ParameterName = 'desiredJournalHistory'; Type = 'Int'; Mandatory = $false; Validation = 'Range' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + 'Set' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAPlannerNetworkPerformanceReport.Tests.ps1 b/Tests/Public/Get-ZAPlannerNetworkPerformanceReport.Tests.ps1 new file mode 100644 index 0000000..357d797 --- /dev/null +++ b/Tests/Public/Get-ZAPlannerNetworkPerformanceReport.Tests.ps1 @@ -0,0 +1,57 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 17 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 17 + } + + $ParameterTestCases = @( + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vmIdentifier'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'recoveryType'; Type = 'String'; Mandatory = $true; Validation = 'Set' } + @{ParameterName = 'interval'; Type = 'Int'; Mandatory = $false; Validation = 'Range' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + 'Set' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAPlannerSite.Tests.ps1 b/Tests/Public/Get-ZAPlannerSite.Tests.ps1 new file mode 100644 index 0000000..0697f3d --- /dev/null +++ b/Tests/Public/Get-ZAPlannerSite.Tests.ps1 @@ -0,0 +1,42 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 12 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 12 + } + + $ParameterTestCases = @( + @{ParameterName = 'siteIdentifier'; Type = 'String[]'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAPlannerStatsReport.Tests.ps1 b/Tests/Public/Get-ZAPlannerStatsReport.Tests.ps1 new file mode 100644 index 0000000..f6b7536 --- /dev/null +++ b/Tests/Public/Get-ZAPlannerStatsReport.Tests.ps1 @@ -0,0 +1,57 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 17 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 17 + } + + $ParameterTestCases = @( + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vmIdentifier'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'recoveryType'; Type = 'String'; Mandatory = $true; Validation = 'Set' } + @{ParameterName = 'desiredJournalHistory'; Type = 'Int'; Mandatory = $false; Validation = 'Range' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + 'Set' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAPlannerWanReport.Tests.ps1 b/Tests/Public/Get-ZAPlannerWanReport.Tests.ps1 new file mode 100644 index 0000000..6f43e52 --- /dev/null +++ b/Tests/Public/Get-ZAPlannerWanReport.Tests.ps1 @@ -0,0 +1,56 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 + } + + $ParameterTestCases = @( + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vmIdentifier'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'recoveryType'; Type = 'String'; Mandatory = $true; Validation = 'Set' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + 'Set' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAPlannerZcasReport.Tests.ps1 b/Tests/Public/Get-ZAPlannerZcasReport.Tests.ps1 new file mode 100644 index 0000000..9940422 --- /dev/null +++ b/Tests/Public/Get-ZAPlannerZcasReport.Tests.ps1 @@ -0,0 +1,56 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 16 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 + } + + $ParameterTestCases = @( + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vmIdentifier'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'recoveryType'; Type = 'String'; Mandatory = $true; Validation = 'Set' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + 'Set' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAProtectedVm.Tests.ps1 b/Tests/Public/Get-ZAProtectedVm.Tests.ps1 new file mode 100644 index 0000000..cb28168 --- /dev/null +++ b/Tests/Public/Get-ZAProtectedVm.Tests.ps1 @@ -0,0 +1,41 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'AllVms'; Type = 'Switch'; Mandatory = $false; Validation = $Null } + @{ParameterName = 'vmIdentifier'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'Volumes'; Type = 'Switch'; Mandatory = $false; Validation = $Null } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAProtectedVmReport.Tests.ps1 b/Tests/Public/Get-ZAProtectedVmReport.Tests.ps1 new file mode 100644 index 0000000..40af444 --- /dev/null +++ b/Tests/Public/Get-ZAProtectedVmReport.Tests.ps1 @@ -0,0 +1,39 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 12 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 12 + } + + $ParameterTestCases = @( + @{ParameterName = 'vmIdentifier'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZARPOAccountAverage.Tests.ps1 b/Tests/Public/Get-ZARPOAccountAverage.Tests.ps1 new file mode 100644 index 0000000..5ba5c2d --- /dev/null +++ b/Tests/Public/Get-ZARPOAccountAverage.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZARPOAverage.Tests.ps1 b/Tests/Public/Get-ZARPOAverage.Tests.ps1 new file mode 100644 index 0000000..eb3a548 --- /dev/null +++ b/Tests/Public/Get-ZARPOAverage.Tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'Interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 60" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 60 + } + + It "Interval Parameter should have a Max value of 2678400" { + (Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 2678400 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZARPOBreach.Tests.ps1 b/Tests/Public/Get-ZARPOBreach.Tests.ps1 new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/Tests/Public/Get-ZARPOBreach.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZARPOStat.Tests.ps1 b/Tests/Public/Get-ZARPOStat.Tests.ps1 new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/Tests/Public/Get-ZARPOStat.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZARPOStatusProportion.Tests.ps1 b/Tests/Public/Get-ZARPOStatusProportion.Tests.ps1 new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/Tests/Public/Get-ZARPOStatusProportion.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZARPOSummary.Tests.ps1 b/Tests/Public/Get-ZARPOSummary.Tests.ps1 new file mode 100644 index 0000000..94b7a9e --- /dev/null +++ b/Tests/Public/Get-ZARPOSummary.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZASite.Tests.ps1 b/Tests/Public/Get-ZASite.Tests.ps1 new file mode 100644 index 0000000..6ce1ca9 --- /dev/null +++ b/Tests/Public/Get-ZASite.Tests.ps1 @@ -0,0 +1,28 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 12 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 12 + } + + It "zOrgIdentifier Parameter should be present and of 'String' Type" { + Get-Command $global:function | Should -HaveParameter zOrgIdentifier -Type String -Mandatory:$false + } + + It "zOrgIdentifier has the NotNullOrEmpty Validator" { + (Get-Command $global:function).Parameters['zOrgIdentifier'].Attributes.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZASitePair.Tests.ps1 b/Tests/Public/Get-ZASitePair.Tests.ps1 new file mode 100644 index 0000000..5ba5c2d --- /dev/null +++ b/Tests/Public/Get-ZASitePair.Tests.ps1 @@ -0,0 +1,44 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZASiteTopology.Tests.ps1 b/Tests/Public/Get-ZASiteTopology.Tests.ps1 new file mode 100644 index 0000000..ebe6cb0 --- /dev/null +++ b/Tests/Public/Get-ZASiteTopology.Tests.ps1 @@ -0,0 +1,42 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 12 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 12 + } + + $ParameterTestCases = @( + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZATask.Tests.ps1 b/Tests/Public/Get-ZATask.Tests.ps1 new file mode 100644 index 0000000..2a38bde --- /dev/null +++ b/Tests/Public/Get-ZATask.Tests.ps1 @@ -0,0 +1,57 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'limitTo'; Type = 'Int'; Mandatory = $false; Validation = 'Range' } + @{ParameterName = 'taskIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Interval Parameter should have a Min value of 1" { + (Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 1 + } + + It "Interval Parameter should have a Max value of 1000000" { + (Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 1000000 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAVolume.Tests.ps1 b/Tests/Public/Get-ZAVolume.Tests.ps1 new file mode 100644 index 0000000..7042d03 --- /dev/null +++ b/Tests/Public/Get-ZAVolume.Tests.ps1 @@ -0,0 +1,45 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'clusterIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'datastoreIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAVpg.Tests.ps1 b/Tests/Public/Get-ZAVpg.Tests.ps1 new file mode 100644 index 0000000..90f9b3f --- /dev/null +++ b/Tests/Public/Get-ZAVpg.Tests.ps1 @@ -0,0 +1,43 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 13 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 13 + } + + $ParameterTestCases = @( + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + Context "$global:function::Parameter Functional Tests" { + + } + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZAzOrg.Tests.ps1 b/Tests/Public/Get-ZAzOrg.Tests.ps1 new file mode 100644 index 0000000..e3e16ee --- /dev/null +++ b/Tests/Public/Get-ZAzOrg.Tests.ps1 @@ -0,0 +1,19 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 11 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 11 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoAlert.Tests.ps1 b/Tests/Public/Get-ZertoAlert.Tests.ps1 index 1367839..9944cda 100644 --- a/Tests/Public/Get-ZertoAlert.Tests.ps1 +++ b/Tests/Public/Get-ZertoAlert.Tests.ps1 @@ -1,29 +1,51 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 - } + Context "$global:function::Parameter Unit Tests" { - Context "$($file.BaseName)::Parameter Unit Tests" { + $ParameterTestCases = @( + @{ParameterName = 'alertId'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'entities'; Type = 'Switch'; Mandatory = $false; Validation = $null } + @{ParameterName = 'helpIdentifiers'; Type = 'Switch'; Mandatory = $false; Validation = $null } + @{ParameterName = 'levels'; Type = 'Switch'; Mandatory = $false; Validation = $null } + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'level'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'helpIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'isDismissed'; Type = 'bool'; Mandatory = $false; Validation = $null } + ) - it "Has a mandatory string parameter for the Alert identifier" { - Get-Command $file.BaseName | Should -HaveParameter alertId -Mandatory -Type String[] + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type } + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + } + } } + Context "$global:function::Parameter Functional Tests" { + + } } +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoDatastore.Tests.ps1 b/Tests/Public/Get-ZertoDatastore.Tests.ps1 index 50d2f9d..a250084 100644 --- a/Tests/Public/Get-ZertoDatastore.Tests.ps1 +++ b/Tests/Public/Get-ZertoDatastore.Tests.ps1 @@ -1,19 +1,25 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + + It "has a non-mandatory string parameter for the datacenterIdentifier" { + Get-Command $global:function | Should -HaveParameter datastoreIdentifier + Get-Command $global:function | Should -HaveParameter datastoreIdentifier -Type String[] + } + + It "datastoreIdentifier parameter does not take null or empty values" { + (Get-Command $global:function).Parameters['datastoreIdentifier'].Attributes.Where{ $_ -is [ValidateNotNullOrEmpty] }.count | Should -Be 1 + } } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoEvent.Tests.ps1 b/Tests/Public/Get-ZertoEvent.Tests.ps1 index 50d2f9d..5e94a0e 100644 --- a/Tests/Public/Get-ZertoEvent.Tests.ps1 +++ b/Tests/Public/Get-ZertoEvent.Tests.ps1 @@ -1,19 +1,120 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -Leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 28 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 28 + } + + $ParameterTestCases = @( + @{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vpg'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'eventType'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'siteName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'entityType'; Type = 'String'; Mandatory = $false; Validation = 'Set' } + @{ParameterName = 'userName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'category'; Type = 'String'; Mandatory = $false; Validation = 'Set' } + @{ParameterName = 'eventCategory'; Type = 'String'; Mandatory = $false; Validation = 'Set' } + @{ParameterName = 'alertIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'eventId'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'categories'; Type = 'Switch'; Mandatory = $true; Validation = $null } + @{ParameterName = 'entities'; Type = 'Switch'; Mandatory = $true; Validation = $null } + @{ParameterName = 'types'; Type = 'Switch'; Mandatory = $true; Validation = $null } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Set' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "entityType parameter only accecpts 4 different values" { + (Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues.Count | Should -Be 4 + } + + It "entityType parameter accecpts 'VPG' as a Value" { + (Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'VPG' + } + + It "entityType parameter accecpts 'VRA' as a Value" { + (Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'VRA' + } + + It "entityType parameter accecpts 'Unknown' as a Value" { + (Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'Unknown' + } + + It "entityType parameter accecpts 'Site' as a Value" { + (Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'Site' + } + + It "category parameter only accecpts 3 different values" { + (Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues.Count | Should -Be 3 + } + + It "category parameter accecpts 'All' as a Value" { + (Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'All' + } + + It "category parameter accecpts 'events' as a Value" { + (Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'events' + } + + It "category parameter accecpts 'alerts' as a Value" { + (Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'alerts' + } + + It "eventCategory parameter only accecpts 3 different values" { + (Get-Command $global:function).Parameters['eventCategory'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues.Count | Should -Be 3 + } + + It "eventCategory parameter accecpts 'All' as a Value" { + (Get-Command $global:function).Parameters['eventCategory'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'All' + } + + It "eventCategory parameter accecpts 'events' as a Value" { + (Get-Command $global:function).Parameters['eventCategory'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'events' + } + + It "eventCategory parameter accecpts 'alerts' as a Value" { + (Get-Command $global:function).Parameters['eventCategory'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'alerts' + } } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoLicense.Tests.ps1 b/Tests/Public/Get-ZertoLicense.Tests.ps1 index 50d2f9d..e3e16ee 100644 --- a/Tests/Public/Get-ZertoLicense.Tests.ps1 +++ b/Tests/Public/Get-ZertoLicense.Tests.ps1 @@ -1,19 +1,19 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 11 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 11 + } } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoLocalSite.Tests.ps1 b/Tests/Public/Get-ZertoLocalSite.Tests.ps1 index 50d2f9d..b82e8a6 100644 --- a/Tests/Public/Get-ZertoLocalSite.Tests.ps1 +++ b/Tests/Public/Get-ZertoLocalSite.Tests.ps1 @@ -1,19 +1,24 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 12 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 12 + } + + It "Has a non-mandatory switch parameter for the pairing Statuses" { + Get-Command $global:function | Should -HaveParameter pairingstatuses + Get-Command $global:function | Should -HaveParameter pairingstatuses -Type switch + } } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoPeerSite.Tests.ps1 b/Tests/Public/Get-ZertoPeerSite.Tests.ps1 index 50d2f9d..16ab624 100644 --- a/Tests/Public/Get-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Get-ZertoPeerSite.Tests.ps1 @@ -1,19 +1,53 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 18 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 18 + } + + $ParameterTestCases = @( + @{ParameterName = 'pairingStatuses'; Type = 'Switch'; Mandatory = $true; Validation = $null } + @{ParameterName = 'siteIdentifier'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'peerName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'paringStatus'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'location'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'hostName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'port'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoProtectedVm.Tests.ps1 b/Tests/Public/Get-ZertoProtectedVm.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoProtectedVm.Tests.ps1 +++ b/Tests/Public/Get-ZertoProtectedVm.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoRecoveryReport.Tests.ps1 b/Tests/Public/Get-ZertoRecoveryReport.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoRecoveryReport.Tests.ps1 +++ b/Tests/Public/Get-ZertoRecoveryReport.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoResourcesReport.Tests.ps1 b/Tests/Public/Get-ZertoResourcesReport.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoResourcesReport.Tests.ps1 +++ b/Tests/Public/Get-ZertoResourcesReport.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoServiceProfile.Tests.ps1 b/Tests/Public/Get-ZertoServiceProfile.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoServiceProfile.Tests.ps1 +++ b/Tests/Public/Get-ZertoServiceProfile.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoTask.Tests.ps1 b/Tests/Public/Get-ZertoTask.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoTask.Tests.ps1 +++ b/Tests/Public/Get-ZertoTask.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 b/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 +++ b/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoVirtualizationSite.Tests.ps1 b/Tests/Public/Get-ZertoVirtualizationSite.Tests.ps1 index 50d2f9d..100a482 100644 --- a/Tests/Public/Get-ZertoVirtualizationSite.Tests.ps1 +++ b/Tests/Public/Get-ZertoVirtualizationSite.Tests.ps1 @@ -1,19 +1,261 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { - - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock } -} \ No newline at end of file + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 23 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 23 + } + + $ParameterTestCases = @( + @{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'hostIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'folders'; Type = 'Switch'; Mandatory = $true; Validation = $Null } + @{ParameterName = 'hostClusters'; Type = 'Switch'; Mandatory = $true; Validation = $Null } + @{ParameterName = 'hosts'; Type = 'Switch'; Mandatory = $true; Validation = $Null } + @{ParameterName = 'networks'; Type = 'Switch'; Mandatory = $true; Validation = $Null } + @{ParameterName = 'resourcePools'; Type = 'Switch'; Mandatory = $true; Validation = $Null } + @{ParameterName = 'vms'; Type = 'Switch'; Mandatory = $true; Validation = $Null } + @{ParameterName = 'repositories'; Type = 'Switch'; Mandatory = $true; Validation = $Null } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting of " -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Validation) + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + Switch ($Validation) { + + 'NotNullOrEmpty' { + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + $Null { + $Type -match 'Switch' | Should -BeTrue -Because "Only Switch Parameters should not have validation" + } + + default { + $true | Should -BeFalse -Because "No Validation Selected. Review test cases" + } + + } + } + + It "$($global:function) does not have 'SupportsShouldProcess'" { + Get-Command $global:function | Should -not -HaveParameter WhatIf + Get-Command $global:function | Should -not -HaveParameter Confirm + $script:ScriptBlock | Should -not -match 'SupportsShouldProcess' + $script:ScriptBlock | Should -not -match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + + } + + Context "$global:function::Parameter Functional Tests" { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-NoParams.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/devices' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-devices.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/devices?hostIdentifier=4567' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-devices-hostid.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/hosts' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-hosts.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/hosts/4567' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-hosts-hostid.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-SiteId.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/datastores' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-datastores.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/datastoreclusters' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-datastoreClusters.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/networks' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-Networks.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/folders' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-Folders.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/hostclusters' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-hostClusters.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/resourcepools' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-ResourcePools.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/vms' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-VMs.json" -Raw) | ConvertFrom-Json + } -Verifiable + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/repositories' + } { + return (Get-Content "$global:here\Mocks\VirtualSite-repositories.json" -Raw) | ConvertFrom-Json + } -Verifiable + + It "Should return all known sites when called without parameters" { + $results = Get-ZertoVirtualizationSite + $results.Count | Should -BeExactly 2 + } + + It "Should return a single site when a siteIdentifier is provided" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' + $results.VirtualizationSiteName | Should -BeExactly 'cavc.nc.lab' + $results.siteIdentifier | Should -BeExactly '8e1c9f53-4973-4a4a-b2dd-1ebb293614d8' + } + + It "Should return a list of devices with the '-devices' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -devices + $results.Count | Should -BeExactly 5 + } + + It "Should return a list of devices with the '-devices' switch and hostIdentifier provided" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -devices -hostIdentifier '4567' + $results.Count | Should -BeExactly 5 + } + + It "Should return a list of hosts with the '-hosts' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -hosts + $results.Count | Should -BeExactly 3 + } + + It "Should return a single host with the '-hosts' switch and hostIdentifier provided" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -hosts -hostIdentifier '4567' + $results.VirtualizationHostName | Should -BeExactly "caesx3.nc.lab" + $results.hostIdentifier | Should -BeExactly "09db6c5b-b956-430f-9589-b58876ca377a.host-18" + } + + It "Should return a list of datastores with the '-datastores' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -datastores + $results.Count | Should -BeExactly 8 + } + + It "Should return a list of datastores with the '-datastoreClusters' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -datastoreClusters + $results.DatastoreClusterIdentifier | Should -BeExactly "09db6c5b-b956-430f-9589-b58876ca377a.group-p44" + $results.DatastoreClusterName | Should -BeExactly "CA_DS_Cluster" + } + + It "Should return a list of Networks with the '-networks' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -networks + $results.NetworkIdentifier | Should -BeExactly "09db6c5b-b956-430f-9589-b58876ca377a.network-20" + $results.VirtualizationNetworkName | Should -BeExactly "VM Network" + } + + It "Should return a list of folders with the '-folders' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -folders + $results.Count | Should -BeExactly 3 + } + + It "Should return a list of Host Clusters with the '-hostClusters' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -hostClusters + $results.ClusterIdentifier | Should -BeExactly "09db6c5b-b956-430f-9589-b58876ca377a.domain-c7" + $results.VirtualizationClusterName | Should -BeExactly "CA Cluster" + } + + It "Should return a list of Resource Pools with the '-resourcePools' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -resourcePools + $results.ResourcePoolIdentifier | Should -BeExactly "09db6c5b-b956-430f-9589-b58876ca377a.resgroup-8" + $results.ResourcePoolName | Should -BeExactly "Resources" + } + + It "Should return a list of VMs with the '-VMs' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -vms + $results.Count | Should -BeExactly 4 + } + + It "Should return a list of LTR Repositories with the '-repositories' switch" { + $results = Get-ZertoVirtualizationSite -siteIdentifier '1234' -repositories + $results.ConnectionType | Should -BeExactly "ServerMessageBlock" + $results.RepositoryIdentifier | Should -BeExactly "120355ce-fcd0-4820-a971-787d0470793b" + $results.RepositoryName | Should -BeExactly "Synology" + $results.StorageType | Should -BeExactly "NetworkShare" + $results.Path | Should -not -be $null + } + + Assert-VerifiableMock + + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/devices' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/devices?hostIdentifier=4567' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/hosts' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/hosts/4567' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/datastores' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/datastoreclusters' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/networks' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/folders' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/hostclusters' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/resourcepools' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/vms' + } -Exactly 1 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -ParameterFilter { + $uri -eq 'virtualizationsites/1234/repositories' + } -Exactly 1 + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoVolume.Tests.ps1 b/Tests/Public/Get-ZertoVolume.Tests.ps1 index 50d2f9d..a46cda1 100644 --- a/Tests/Public/Get-ZertoVolume.Tests.ps1 +++ b/Tests/Public/Get-ZertoVolume.Tests.ps1 @@ -1,19 +1,18 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global + diff --git a/Tests/Public/Get-ZertoVpg.Tests.ps1 b/Tests/Public/Get-ZertoVpg.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Get-ZertoVpg.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoVpgSetting.Tests.ps1 b/Tests/Public/Get-ZertoVpgSetting.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoVpgSetting.Tests.ps1 +++ b/Tests/Public/Get-ZertoVpgSetting.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoVra.Tests.ps1 b/Tests/Public/Get-ZertoVra.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoVra.Tests.ps1 +++ b/Tests/Public/Get-ZertoVra.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoZorg.Tests.ps1 b/Tests/Public/Get-ZertoZorg.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoZorg.Tests.ps1 +++ b/Tests/Public/Get-ZertoZorg.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Get-ZertoZsspSession.Tests.ps1 b/Tests/Public/Get-ZertoZsspSession.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Get-ZertoZsspSession.Tests.ps1 +++ b/Tests/Public/Get-ZertoZsspSession.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Import-ZertoVmNicSetting.Tests.ps1 b/Tests/Public/Import-ZertoVmNicSetting.Tests.ps1 new file mode 100644 index 0000000..20db68c --- /dev/null +++ b/Tests/Public/Import-ZertoVmNicSetting.Tests.ps1 @@ -0,0 +1,30 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 11 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + It "Has a mandatory string array parameter for the settings file to import" { + Get-Command $global:function | Should -HaveParameter InputFile + Get-Command $global:function | Should -HaveParameter InputFile -Mandatory + Get-Command $global:function | Should -HaveParameter InputFile -Type String + } + + It "Will not accecpt a Null or Empty string for the settings file" { + $attrs = (Get-Command $global:function).Parameters['InputFile'].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Import-ZertoVpg.Tests.ps1 b/Tests/Public/Import-ZertoVpg.Tests.ps1 index bd91e77..6b48c30 100644 --- a/Tests/Public/Import-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Import-ZertoVpg.Tests.ps1 @@ -1,39 +1,30 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 - } - - Context "$($file.BaseName)::Parameter Unit Tests" { + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 12 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 12 + } It "Has a mandatory string array parameter for the settings file to import" { - Get-Command $file.BaseName | Should -HaveParameter settingsFile - Get-Command $file.BaseName | Should -HaveParameter settingsFile -Mandatory - Get-Command $file.BaseName | Should -HaveParameter settingsFile -Type String[] + Get-Command $global:function | Should -HaveParameter settingsFile + Get-Command $global:function | Should -HaveParameter settingsFile -Mandatory + Get-Command $global:function | Should -HaveParameter settingsFile -Type String[] } It "Will not accecpt a Null or Empty string for the settings file" { - {Import-ZertoVpg -settingsFile $null} | Should -Throw - {Import-ZertoVpg -settingsFile ""} | Should -Throw - {Import-ZertoVpg -settingsFile @()} | Should -Throw + $attrs = (Get-Command $global:function).Parameters['settingsFile'].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 } - } - Context "$($file.BaseName)::Function Unit Tests" { + Context "$global:function::Parameter Functional Tests" { } } + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Install-ZertoVra.Tests.ps1 b/Tests/Public/Install-ZertoVra.Tests.ps1 index 598a6e4..a5005d3 100644 --- a/Tests/Public/Install-ZertoVra.Tests.ps1 +++ b/Tests/Public/Install-ZertoVra.Tests.ps1 @@ -1,108 +1,57 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 24 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 24 + } + + $ParameterTestCases = @( + @{ParameterName = 'hostName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'datastoreName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'networkName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'Dhcp'; Type = 'Switch'; Mandatory = $true; Validation = $null } + @{ParameterName = 'vraIpAddress'; Type = 'String'; Mandatory = $true; Validation = 'IpAddr' } + @{ParameterName = 'subnetMask'; Type = 'String'; Mandatory = $true; Validation = 'IpAddr' } + @{ParameterName = 'defaultGateway'; Type = 'String'; Mandatory = $true; Validation = 'IpAddr' } + @{ParameterName = 'UseRootCredential'; Type = 'Switch'; Mandatory = $true; Validation = $null } + @{ParameterName = 'HostRootPassword'; Type = 'SecureString'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'IpAddr' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateScript] }.Count | Should -Be 1 + $attrs.Where{ $_ -is [ValidateScript] }.ScriptBlock | Should -Match '\$_ \-match \[IPAddress\]\$_' + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 3 + } + } + } } - Context "$($file.BaseName)::Parameter Unit Tests" { + Context "$global:function::Parameter Functional Tests" { - It "Has a mandatory string host name parameter" { - Get-Command $file.BaseName | Should -HaveParameter hostName - Get-Command $file.BaseName | Should -HaveParameter hostName -Mandatory - Get-Command $file.BaseName | Should -HaveParameter hostName -Type String - } - - It "Will not accecpt a Null or Empty string for the host name" { - {Install-ZertoVra -hostName $null -datastoreName "DS01" -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty" - {Install-ZertoVra -hostName "" -datastoreName "DS01" -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty" - } - - It "Has a mandatory string datastore parameter" { - Get-Command $file.BaseName | Should -HaveParameter datastoreName - Get-Command $file.BaseName | Should -HaveParameter datastoreName -Mandatory - Get-Command $file.BaseName | Should -HaveParameter datastoreName -Type String - } - - It "Will not accecpt a Null or Empty string for the datastore" { - {Install-ZertoVra -hostName "MyfirstHost" -datastoreName $null -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty" - {Install-ZertoVra -hostName "MyfirstHost" -datastoreName "" -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty" - } - - It "Has a mandatory string network parameter" { - Get-Command $file.BaseName | Should -HaveParameter networkName - Get-Command $file.BaseName | Should -HaveParameter networkName -Mandatory - Get-Command $file.BaseName | Should -HaveParameter networkName -Type String - } - - It "Will not accecpt a Null or Empty string for the datastore" { - {Install-ZertoVra -hostName "MyfirstHost" -datastoreName "DS01" -networkName $null -Dhcp } | Should -Throw "The argument is null or empty" - {Install-ZertoVra -hostName "MyfirstHost" -datastoreName "DS01" -networkName "" -Dhcp } | Should -Throw "The argument is null or empty" - } - - it "Has a switch parameter for setting DHCP" { - Get-Command $file.BaseName | Should -HaveParameter Dhcp - Get-Command $file.BaseName | Should -HaveParameter Dhcp -Mandatory - Get-Command $file.BaseName | Should -HaveParameter Dhcp -Type 'Switch' - - } - - it "Has a mandatory string parameter for the static IP address" { - Get-Command $file.BaseName | Should -HaveParameter vraIpAddress - Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Mandatory - Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Type String - } - - it "Has a mandatory string parameter for the subnet mask" { - Get-Command $file.BaseName | Should -HaveParameter subnetMask - Get-Command $file.BaseName | Should -HaveParameter subnetMask -Mandatory - Get-Command $file.BaseName | Should -HaveParameter subnetMask -Type String - } - - it "Has a mandatory string parameter for the default gateway" { - Get-Command $file.BaseName | Should -HaveParameter defaultGateway - Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Mandatory - Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Type String - } - - $cases = ` - @{invalidIpAddress = "192.168.1.256"}, ` - @{invalidIpAddress = "192.168.1"}, ` - @{invalidIpAddress = "String"}, ` - @{invalidIpAddress = 192.168.1.246}, ` - @{invalidIpAddress = 32}, ` - @{invalidIpAddress = ""}, ` - @{invalidIpAddress = $null} - It "IpAddress field require valid IP addresses as a String: " -TestCases $cases { - param ( $invalidIpAddress ) - {Install-ZertoVra -hostName "MyFirstHost" -datastoreName "DS01" -networkName "MyNetwork" -vraIpAddress $invalidIpAddress -subnetMask "255.255.255.0" -defaultGateway "192.168.1.254"} | Should -Throw - } - - It "Default Gateway field require valid IP addresses as a String: " -TestCases $cases { - param ( $invalidIpAddress ) - {Install-ZertoVra -hostName "MyFirstHost" -datastoreName "DS01" -networkName "MyNetwork" -vraIpAddress '192.168.1.100' -subnetMask "255.255.255.0" -defaultGateway $invalidIpAddress} | Should -Throw - } - - It "Subnet Mask field require valid IP addresses as a String: " -TestCases $cases { - param ( $invalidIpAddress ) - {Install-ZertoVra -hostName "MyFirstHost" -datastoreName "DS01" -networkName "MyNetwork" -vraIpAddress '192.168.1.100' -subnetMask $invalidIpAddress -defaultGateway "192.168.1.254"} | Should -Throw - } - - } - - Context "$($file.BaseName)::Function Unit Tests" { - #TODO } } + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Invoke-ZARestRequest.Tests.ps1 b/Tests/Public/Invoke-ZARestRequest.Tests.ps1 new file mode 100644 index 0000000..983c373 --- /dev/null +++ b/Tests/Public/Invoke-ZARestRequest.Tests.ps1 @@ -0,0 +1,90 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + InModuleScope -ModuleName ZertoApiWrapper { + + Context "$global:function::Parameter Unit Tests" { + + $testCases = @( + @{ParameterName = 'uri'; Type = 'String'; Mandatory = $true; TestName = 'URI' } + @{ParameterName = 'method'; Type = 'String'; Mandatory = $false; TestName = 'Method' } + @{ParameterName = 'body'; Type = 'String'; Mandatory = $false; TestName = 'Body' } + ) + + It "Parameter present and Type test for: " -TestCases $testCases { + param($parameterName, $type, $Mandatory) + Get-Command $global:function | Should -HaveParameter $parameterName -Type $type + if ($Mandatory) { + Get-Command $global:function | Should -HaveParameter $parameterName -Mandatory + } else { + Get-Command $global:function | Should -HaveParameter $parameterName -Not -Mandatory + } + } + + It "Method parameter default is 'GET'" { + Get-Command $global:function | Should -HaveParameter Method -DefaultValue "GET" + } + + $NotNullOrEmptyTests = @( + @{ParameterName = 'uri'; TestName = 'Uri' } + @{ParameterName = 'body'; TestName = 'Body' } + ) + + It " parameter does not accecpt a null or empty value" -TestCases $NotNullOrEmptyTests { + param($parameterName) + $parameterInfo = ( Get-Command Invoke-ZARestRequest ).Parameters[$parameterName] + $parameterInfo.Attributes.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + It "method parametert only accecpts 'GET' 'DELETE' 'PUT' 'POST' values" { + $parameterInfo = ( Get-Command Invoke-ZARestRequest ).Parameters['method'] + $parameterInfo.Attributes.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + $validateSet = $parameterInfo.Attributes.Where{ $_ -is [ValidateSet] } + $validateSet.ValidValues -contains 'GET' | Should -BeTrue + $validateSet.ValidValues -contains 'PUT' | Should -BeTrue + $validateSet.ValidValues -contains 'POST' | Should -BeTrue + $validateSet.ValidValues -contains 'DELETE' | Should -BeTrue + $validateSet.ValidValues.Count | Should -Be 4 + } + } + + Context "$global:function::Function Unit Tests" { + + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-RestMethod { + "Ran Command" + } + + BeforeEach { + Set-Variable -Name zaHeaders -Scope Script -Value (@{ "Accept" = "application/json" }) + Set-Variable -Name zaLastActionTime -Scope Script -Value $(Get-Date).Ticks + } + + It "runs when called" { + Invoke-ZARestRequest -uri "myuri" | Should -Be "Ran Command" + } + + It "throws when the last action was over 60 minutes ago" { + $script:zaLastActionTime = (Get-Date).AddMinutes(-61).Ticks + { Invoke-ZARestRequest -uri "myuri" } | Should Throw "Authorization Token has Expired." + } + + It "throws when the zaHeaders variable does not exits" { + Remove-Variable -Name zaHeaders -Scope Script + { Invoke-ZARestRequest -uri "myuri" } | Should Throw "Zerto Analytics Connection does not Exist." + } + + It "throws when the zaLastActionTime variable does not exist" { + Remove-Variable -Name zaLastActionTime -Scope Script + { Invoke-ZARestRequest -uri "myuri" } | Should Throw "Zerto Analytics Connection does not Exist." + } + + Assert-MockCalled -CommandName Invoke-RestMethod -ModuleName ZertoApiWrapper -Exactly 1 + } + } +} + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Invoke-ZertoEvacuateVra.Tests.ps1 b/Tests/Public/Invoke-ZertoEvacuateVra.Tests.ps1 new file mode 100644 index 0000000..cfd3c2e --- /dev/null +++ b/Tests/Public/Invoke-ZertoEvacuateVra.Tests.ps1 @@ -0,0 +1,54 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 16 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 + } + + $ParameterTestCases = @( + @{ParameterName = 'hostName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty'; ParameterSet = @('hostName') } + @{ParameterName = 'vraName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' ; ParameterSet = @('vraName') } + @{ParameterName = 'vraIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' ; ParameterSet = @('vraIdentifier') } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + } + } + + It " parameter is part of the correct ParameterSet(s)" -TestCases $ParameterTestCases { + param($ParameterName, $ParameterSet) + $commandParameterSets = (Get-Command $global:function).Parameters[$ParameterName].ParameterSets + foreach ($Set in $ParameterSet) { + $commandParameterSets.ContainsKey($Set) | Should -BeTrue + } + $commandParameterSets.Count | Should -Be $ParameterSet.Count + } + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Invoke-ZertoFailover.Tests.ps1 b/Tests/Public/Invoke-ZertoFailover.Tests.ps1 index 8582291..88e38bd 100644 --- a/Tests/Public/Invoke-ZertoFailover.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailover.Tests.ps1 @@ -1,77 +1,101 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 - } - - Context "$($file.BaseName)::Parameter Unit Tests" { - it "has a mandatory string parameter for the vpgName" { - Get-Command $file.BaseName | Should -HaveParameter vpgName - Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string - Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 20 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 20 } - it "has a non-mandatory string parameter for the checkpoint" { - Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier - Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Type string - Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Not -Mandatory + $ParameterTestCases = @( + @{ParameterName = 'vpgName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'checkpointIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'commitPolicy'; Type = 'String'; Mandatory = $false; Validation = 'Set' } + @{ParameterName = 'shutdownPolicy'; Type = 'Int'; Mandatory = $false; Validation = 'Set' } + @{ParameterName = 'timeToWaitBeforeShutdownInSec'; Type = 'Int'; Mandatory = $false; Validation = 'Range' } + @{ParameterName = 'reverseProtection'; Type = 'bool'; Mandatory = $false; Validation = $null } + @{ParameterName = 'vmName'; Type = 'String[]'; Mandatory = $false; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type } - it "has a non-mandatory string parameter for the commit policy" { - Get-Command $file.BaseName | Should -HaveParameter commitPolicy - Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Type string - Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter commitPolicy -DefaultValue "Rollback" + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Set' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + 'ShouldProcess' { + $scriptBlock = (Get-Command $global:function).ScriptBlock + $scriptBlock | Should -match 'SupportsShouldProcess' + $scriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } } - it "has a non-mandatory int parameter for the shutdown policy" { - Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy - Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Type int - Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -DefaultValue 0 + It "Commit Policy Default Value is 'RollBack'" { + Get-Command $global:function | Should -HaveParameter commitPolicy -DefaultValue "Rollback" } - it "has a non-mandatory int parameter for the time to wait before force shutdown" { - Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec - Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Type int - Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -DefaultValue 3600 + It "Commit Policy Only Accecpts 'RollBack', 'Commit', or 'None'" { + (Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -HaveCount 3 + (Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'RollBack' + (Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'Commit' + (Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'None' } - it "has a non-mandatory bool parameter for the reverse protection policy" { - Get-Command $file.BaseName | Should -HaveParameter reverseProtection - Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type bool - Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Not -Mandatory + It "Shutdown Policy Default Value is '0'" { + Get-Command $global:function | Should -HaveParameter shutdownPolicy -DefaultValue 0 } - it "has a non-mandatory array string parameter for the named VMs to be failed over" { - Get-Command $file.BaseName | Should -HaveParameter vmName - Get-Command $file.BaseName | Should -HaveParameter vmName -Type string[] - Get-Command $file.BaseName | Should -HaveParameter vmName -Not -Mandatory + It "Shutdown Policy Only Accecpts 'RollBack', 'Commit', or 'None'" { + (Get-Command $global:function).Parameters['shutdownPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -HaveCount 3 + (Get-Command $global:function).Parameters['shutdownPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 0 + (Get-Command $global:function).Parameters['shutdownPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 1 + (Get-Command $global:function).Parameters['shutdownPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 2 } - it "Supports 'SupportsShouldProcess'" { - Get-Command $file.BaseName | Should -HaveParameter WhatIf - Get-Command $file.BaseName | Should -HaveParameter Confirm - $file | Should -FileContentMatch 'SupportsShouldProcess' - $file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' + It "Time to wait before shutdown in sec should have a default value of 3600" { + Get-Command $global:function | Should -HaveParameter timeToWaitBeforeShutdownInSec -DefaultValue 3600 + } + + It "Time to wait before shutdown in sec should have a minimum value of 300 and max value of 86400" { + (Get-Command $global:function).Parameters['timeToWaitBeforeShutdownInSec'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 300 + (Get-Command $global:function).Parameters['timeToWaitBeforeShutdownInSec'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 86400 } } - Context "$($file.BaseName)::Function Unit Tests" { - #TODO + Context "$global:function::Parameter Functional Tests" { + } } + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 b/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 index 2fa2e2e..5c59b8b 100644 --- a/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 @@ -1,44 +1,56 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 - } + Context "$global:function::Parameter Unit Tests" { - Context "$($file.BaseName)::Parameter Unit Tests" { - - it "Supports 'ShouldProcess'" { - Get-Command $file.BaseName | Should -HaveParameter WhatIf - Get-Command $file.BaseName | Should -HaveParameter Confirm - $file | Should -FileContentMatch 'SupportsShouldProcess' - $file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 } - it "has a mandatory string parameter for the vpgName" { - Get-Command $file.BaseName | Should -HaveParameter vpgName - Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string[] - Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory + $ParameterTestCases = @( + @{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'reverseProtection'; Type = 'switch'; Mandatory = $false; Validation = $null } + @{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type } - it "has a switch parameter for reverse protection" { - Get-Command $file.BaseName | Should -HaveParameter reverseProtection - Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type switch + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'ShouldProcess' { + $scriptBlock = (Get-Command $global:function).ScriptBlock + $scriptBlock | Should -match 'SupportsShouldProcess' + $scriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } } } - Context "$($file.BaseName)::Function Unit Tests" { - #TODO + Context "$global:function::Parameter Functional Tests" { + } } + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Invoke-ZertoFailoverRollback.Tests.ps1 b/Tests/Public/Invoke-ZertoFailoverRollback.Tests.ps1 index 50d2f9d..248b8f1 100644 --- a/Tests/Public/Invoke-ZertoFailoverRollback.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailoverRollback.Tests.ps1 @@ -1,19 +1,25 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + + It "$global:function should have exactly 12 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 12 + } + + It "has a mandatory string parameter for the vpgName" { + Get-Command $global:function | Should -HaveParameter vpgName + Get-Command $global:function | Should -HaveParameter vpgName -Type string[] + Get-Command $global:function | Should -HaveParameter vpgName -Mandatory + } } -} \ No newline at end of file + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Invoke-ZertoForceSync.Tests.ps1 b/Tests/Public/Invoke-ZertoForceSync.Tests.ps1 index 50d2f9d..e35259a 100644 --- a/Tests/Public/Invoke-ZertoForceSync.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoForceSync.Tests.ps1 @@ -1,19 +1,26 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + + It "$global:function should have exactly 12 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 12 + } + + It "has a mandatory string parameter for the vpgName" { + Get-Command $global:function | Should -HaveParameter vpgName + Get-Command $global:function | Should -HaveParameter vpgName -Type string[] + Get-Command $global:function | Should -HaveParameter vpgName -Mandatory + } } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Invoke-ZertoMove.Tests.ps1 b/Tests/Public/Invoke-ZertoMove.Tests.ps1 index 50d2f9d..efb1260 100644 --- a/Tests/Public/Invoke-ZertoMove.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoMove.Tests.ps1 @@ -1,19 +1,83 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 21 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 21 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgIdentifier'; Type = 'Guid[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'commitPolicy'; Type = 'String'; Mandatory = $false; Validation = 'Set' } + @{ParameterName = 'commitPolicyTimeout'; Type = 'Int'; Mandatory = $false; Validation = 'Range' } + @{ParameterName = 'forceShutdown'; Type = 'Switch'; Mandatory = $false; Validation = $null } + @{ParameterName = 'disableReverseProtection'; Type = 'Switch'; Mandatory = $false; Validation = $null } + @{ParameterName = 'keepSourceVms'; Type = 'Switch'; Mandatory = $false; Validation = $null } + @{ParameterName = 'ContinueOnPreScriptFailure'; Type = 'Switch'; Mandatory = $false; Validation = $null } + @{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'Set' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + } + + 'Range' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1 + } + + 'ShouldProcess' { + $scriptBlock = (Get-Command $global:function).ScriptBlock + $scriptBlock | Should -match 'SupportsShouldProcess' + $scriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Commit Policy Only Accecpts 'RollBack', 'Commit', or 'None'" { + (Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -HaveCount 3 + (Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'RollBack' + (Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'Commit' + (Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'None' + } + + It "Commit Policy Timeout should have a minimum value of 300 and max value of 86400" { + (Get-Command $global:function).Parameters['commitPolicyTimeout'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 300 + (Get-Command $global:function).Parameters['commitPolicyTimeout'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 86400 + } } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Invoke-ZertoMoveCommit.Tests.ps1 b/Tests/Public/Invoke-ZertoMoveCommit.Tests.ps1 index 50d2f9d..06b7449 100644 --- a/Tests/Public/Invoke-ZertoMoveCommit.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoMoveCommit.Tests.ps1 @@ -1,19 +1,56 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + + It "$global:function should have exactly 16 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 16 + } + + $ParameterTestCases = @( + @{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'reverseProtection'; Type = 'switch'; Mandatory = $false; Validation = $null } + @{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + 'ShouldProcess' { + $scriptBlock = (Get-Command $global:function).ScriptBlock + $scriptBlock | Should -match 'SupportsShouldProcess' + $scriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + + $null { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.TypeId.Count | Should -Be 2 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Invoke-ZertoMoveRollback.Tests.ps1 b/Tests/Public/Invoke-ZertoMoveRollback.Tests.ps1 index 50d2f9d..8e0b4fd 100644 --- a/Tests/Public/Invoke-ZertoMoveRollback.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoMoveRollback.Tests.ps1 @@ -1,19 +1,25 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 + Context "$global:function::Parameter Unit Tests" { + + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + It "has a mandatory string parameter for the vpgName" { + Get-Command $global:function | Should -HaveParameter vpgName + Get-Command $global:function | Should -HaveParameter vpgName -Type string[] + Get-Command $global:function | Should -HaveParameter vpgName -Mandatory + } } -} \ No newline at end of file + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Invoke-ZertoRestRequest.Tests.ps1 b/Tests/Public/Invoke-ZertoRestRequest.Tests.ps1 new file mode 100644 index 0000000..16ed79e --- /dev/null +++ b/Tests/Public/Invoke-ZertoRestRequest.Tests.ps1 @@ -0,0 +1,89 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + InModuleScope -ModuleName ZertoApiWrapper { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-RestMethod { + "Ran Command" + } + + Context "$global:function::Parameter Unit Tests" { + $thisCommand = Get-Command Invoke-ZertoRestRequest + $ParameterNameTestCases = @( + @{ParameterName = "uri"; Type = "String"; Mandatory = $true; DefaultValue = $null; TestName = "URI" } + @{ParameterName = "method"; Type = "String"; Mandatory = $false; DefaultValue = 'GET'; TestName = "Method" } + @{ParameterName = "body"; Type = "String"; Mandatory = $false; DefaultValue = $null; TestName = "Body" } + @{ParameterName = "credential"; Type = "PSCredential"; Mandatory = $false; DefaultValue = $null; TestName = "Credential" } + @{ParameterName = "returnHeaders"; Type = "Switch"; Mandatory = $false; DefaultValue = $null; TestName = "Return Headers" } + ) + + It " parameter has the right Type, Default Value, and Mandatory Setting" -TestCases $ParameterNameTestCases { + param($ParameterName, $Type, $DefaultValue, $Mandatory) + if ($Mandatory) { + $thisCommand | Should -HaveParameter $ParameterName -Type $Type -Mandatory + } else { + $thisCommand | Should -HaveParameter $ParameterName -Type $Type + $thisCommand | Should -HaveParameter $ParameterName -Not -Mandatory + } + if ($null -ne $DefaultValue) { + $thisCommand | Should -HaveParameter $ParameterName -DefaultValue $DefaultValue + } + } + + $ParameterValidationTestCases = @( + @{ParameterName = "URI"; TestName = "URI" } + @{ParameterName = "body"; TestName = "Body" } + ) + + It " parameter cannot be null or empty" -TestCases $ParameterValidationTestCases { + param($ParameterName) + $thisParameter = $thisCommand.Parameters[$ParameterName] + $thisParameter.Attributes.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + It "Method parameter can only be 'GET', 'POST', 'PUT', 'DELETE'" { + $thisParameter = $thisCommand.Parameters['method'] + $thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1 + $thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues -contains 'GET' | Should -BeTrue + $thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues -contains 'PUT' | Should -BeTrue + $thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues -contains 'POST' | Should -BeTrue + $thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues -contains 'DELETE' | Should -BeTrue + $thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues.Count | Should -Be 4 + } + } + + Context "$global:function::Function Unit Tests" { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-RestMethod { + "Ran Command" + } + + BeforeEach { + Set-Variable -Name zvmHeaders -Scope Script -Value (@{ "Accept" = "application/json" }) + Set-Variable -Name zvmLastAction -Scope Script -Value $(Get-Date).Ticks + Set-Variable -Name zvmServer -Scope Script -Value "192.168.1.100" + Set-Variable -Name zvmPort -Scope Script -Value 9669 + } + + It "runs when called" { + Invoke-ZertoRestRequest -uri "MyUri" | Should -Be "Ran Command" + } + + It "throws an error when zvmLastAction was more than 30 minutes ago" { + Set-Variable -Name zvmLastAction -Scope Script -Value $(Get-Date).AddMinutes(-31).Ticks + { Invoke-ZertoRestRequest -uri "MyUri" } | Should Throw "Authorization Token has Expired" + } + + It "throws an error when the zvmServer variable does not exist" { + Remove-Variable -Name zvmServer -Scope Script + { Invoke-ZertoRestRequest -uri "MyUri" } | Should Throw "Zerto Connection does not Exist." + } + + Assert-MockCalled -CommandName Invoke-RestMethod -ModuleName ZertoApiWrapper -Exactly 1 + } + } +} + +Remove-Variable -Name function -Scope Global +Remove-Variable -Name here -Scope Global diff --git a/Tests/Public/Mocks/AuthHeaders.json b/Tests/Public/Mocks/AuthHeaders.json new file mode 100644 index 0000000..6f904f8 --- /dev/null +++ b/Tests/Public/Mocks/AuthHeaders.json @@ -0,0 +1,23 @@ +{ + "apiRequestResults": "", + "Headers": { + "Cache-Control": [ + "no-cache" + ], + "Server": [ + "Microsoft-HTTPAPI/2.0" + ], + "x-zerto-session": [ + "e34da0b0-4bc2-4cda-b316-0384e35bdca5" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Thu, 11 Jul 2019 19:05:40 GMT" + ], + "Content-Length": [ + "0" + ] + } +} diff --git a/Tests/Public/Mocks/CopyVpgSettings.json b/Tests/Public/Mocks/CopyVpgSettings.json new file mode 100644 index 0000000..07f85c3 --- /dev/null +++ b/Tests/Public/Mocks/CopyVpgSettings.json @@ -0,0 +1,79 @@ +{ + "Basic": { + "JournalHistoryInHours": 24, + "Name": "Test-SQL_Copy_1", + "Priority": "Medium", + "ProtectedSiteIdentifier": "15aa0d43-69cd-400a-8b99-fe94bbac3e19", + "RecoverySiteIdentifier": "8e1c9f53-4973-4a4a-b2dd-1ebb293614d8", + "RpoInSeconds": 300, + "ServiceProfileIdentifier": null, + "TestIntervalInMinutes": 262080, + "UseWanCompression": true, + "ZorgIdentifier": null + }, + "BootGroups": { + "BootGroups": [ + "@{BootDelayInSeconds=0; BootGroupIdentifier=00000000-0000-0000-0000-000000000000; Name=Default}" + ] + }, + "Journal": { + "DatastoreIdentifier": null, + "Limitation": { + "HardLimitInMB": 153600, + "HardLimitInPercent": 0, + "WarningThresholdInMB": 115200, + "WarningThresholdInPercent": 0 + } + }, + "LongTermRetention": null, + "Networks": { + "Failover": { + "Hypervisor": "@{DefaultNetworkIdentifier=09db6c5b-b956-430f-9589-b58876ca377a.network-20}", + "PublicCloud": null, + "VCD": null + }, + "FailoverTest": { + "Hypervisor": "@{DefaultNetworkIdentifier=09db6c5b-b956-430f-9589-b58876ca377a.network-20}", + "PublicCloud": null, + "VCD": null + } + }, + "Protected": { + "VCD": null + }, + "Recovery": { + "DefaultDatastoreClusterIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.group-p44", + "DefaultDatastoreIdentifier": null, + "DefaultFolderIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.group-v3", + "DefaultHostClusterIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.domain-c7", + "DefaultHostIdentifier": null, + "PublicCloud": null, + "ResourcePoolIdentifier": null, + "VCD": null + }, + "Scripting": { + "PostBackup": null, + "PostRecovery": { + "Command": null, + "Parameters": null, + "TimeoutInSeconds": 300 + }, + "PreRecovery": { + "Command": null, + "Parameters": null, + "TimeoutInSeconds": 300 + } + }, + "Vms": [ + { + "BootGroupIdentifier": "00000000-0000-0000-0000-000000000000", + "Journal": "@{DatastoreIdentifier=; Limitation=}", + "Nics": "", + "Recovery": "@{DatastoreClusterIdentifier=09db6c5b-b956-430f-9589-b58876ca377a.group-p44; DatastoreIdentifier=; FolderIdentifier=09db6c5b-b956-430f-9589-b58876ca377a.group-v3; HostClusterIdentifier=09db6c5b-b956-430f-9589-b58876ca377a.domain-c7; HostIdentifier=; PublicCloud=; ResourcePoolIdentifier=; VCD=}", + "VmIdentifier": "d809de8e-deb7-45cc-b620-08030a1143e1.vm-87", + "Volumes": "" + } + ], + "VpgIdentifier": null, + "VpgSettingsIdentifier": "0be951ef-229a-401c-9e0d-bd8a5baea19a" +} diff --git a/Tests/Public/Mocks/GetDhcpVra.json b/Tests/Public/Mocks/GetDhcpVra.json new file mode 100644 index 0000000..0c2539c --- /dev/null +++ b/Tests/Public/Mocks/GetDhcpVra.json @@ -0,0 +1,50 @@ +{ + "DatastoreClusterIdentifier": null, + "DatastoreClusterName": null, + "DatastoreIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.datastore-21", + "DatastoreName": "datastore1 (2)", + "HostIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.host-18", + "HostVersion": "6.7", + "IpAddress": "192.168.10.110", + "Link": { + "href": "https://192.168.10.20:9669/v1/vras/5377857665828094938", + "identifier": "5377857665828094938", + "rel": null, + "type": "VraApi" + }, + "Link_{0}": { + "href": "https://192.168.10.20:9669/v1/vras/5377857665828094938", + "rel": "self", + "type": "VraApi" + }, + "MemoryInGB": 1, + "NetworkIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.network-22", + "NetworkName": "VM Network", + "Progress": 0, + "ProtectedCounters": { + "Vms": 0, + "Volumes": 0, + "Vpgs": 0 + }, + "RecoveryCounters": { + "Vms": 0, + "Volumes": 0, + "Vpgs": 0 + }, + "SelfProtectedVpgs": 0, + "Status": 0, + "VraAlerts": { + "VraAlertsStatus": 0 + }, + "VraGroup": "default_group", + "VraIdentifier": 5377857665828094938, + "VraIdentifierStr": "5377857665828094938", + "VraName": "Z-VRA-ncesx1.nc.lab", + "VraNetworkDataApi": { + "DefaultGateway": "", + "SubnetMask": "255.255.255.0", + "VraIPAddress": "192.168.10.110", + "VraIPConfigurationTypeApi": "Dhcp" + }, + "VraVersion": "7.0" +} diff --git a/Tests/Public/Mocks/GetSingleVra.json b/Tests/Public/Mocks/GetSingleVra.json new file mode 100644 index 0000000..df9776c --- /dev/null +++ b/Tests/Public/Mocks/GetSingleVra.json @@ -0,0 +1,50 @@ +{ + "DatastoreClusterIdentifier": null, + "DatastoreClusterName": null, + "DatastoreIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.datastore-19", + "DatastoreName": "datastore1", + "HostIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.host-15", + "HostVersion": "6.7", + "IpAddress": "192.168.10.15", + "Link": { + "href": "https://192.168.10.20:9669/v1/vras/5377857665828093654", + "identifier": "5377857665828093654", + "rel": null, + "type": "VraApi" + }, + "Link_{0}": { + "href": "https://192.168.10.20:9669/v1/vras/5377857665828093654", + "rel": "self", + "type": "VraApi" + }, + "MemoryInGB": 1, + "NetworkIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.network-22", + "NetworkName": "VM Network", + "Progress": 0, + "ProtectedCounters": { + "Vms": 0, + "Volumes": 0, + "Vpgs": 0 + }, + "RecoveryCounters": { + "Vms": 0, + "Volumes": 0, + "Vpgs": 0 + }, + "SelfProtectedVpgs": 0, + "Status": 0, + "VraAlerts": { + "VraAlertsStatus": 0 + }, + "VraGroup": "default_group", + "VraIdentifier": 5377857665828093654, + "VraIdentifierStr": "5377857665828093654", + "VraName": "Z-VRA-ncesx2.nc.lab", + "VraNetworkDataApi": { + "DefaultGateway": "192.168.10.254", + "SubnetMask": "255.255.255.0", + "VraIPAddress": "192.168.10.15", + "VraIPConfigurationTypeApi": "Static" + }, + "VraVersion": "7.0" +} diff --git a/Tests/Public/Mocks/GetVpg.json b/Tests/Public/Mocks/GetVpg.json new file mode 100644 index 0000000..f1766dc --- /dev/null +++ b/Tests/Public/Mocks/GetVpg.json @@ -0,0 +1,75 @@ +{ + "ActiveProcessesApi": { + "RunningFailOverTestApi": null + }, + "ActualRPO": 7, + "BackupEnabled": false, + "ConfiguredRpoSeconds": 300, + "Entities": { + "Protected": 0, + "Recovery": 0, + "Source": 0, + "Target": 0 + }, + "FailSafeHistory": { + "ActualFailSafeHistory": 60, + "ConfiguredFailSafeHistory": 240, + "FailSafeDescription": "" + }, + "HistoryStatusApi": { + "ActualHistoryInMinutes": 92, + "ConfiguredHistoryInMinutes": 1440, + "EarliestCheckpoint": { + "CheckpointIdentifier": "786", + "Tag": null, + "TimeStamp": "2019-07-20T19:30:19Z" + } + }, + "IOPs": 13, + "LastTest": null, + "Link": { + "href": "https://192.168.10.20:9669/v1/vpgs/57f502ff-3c41-4aff-b20a-6638205b73cd", + "identifier": "57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": null, + "type": "VpgApi" + }, + "Link_{0}": { + "href": "https://192.168.10.20:9669/v1/vpgs/57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": "self", + "type": "VpgApi" + }, + "OrganizationName": "", + "Priority": 1, + "ProgressPercentage": 0, + "ProtectedSite": { + "href": "https://192.168.10.20:9669/v1/localsite", + "identifier": "9e09efa0-0d00-46ed-929b-f86273b28205", + "rel": null, + "type": "LocalSiteApi" + }, + "ProvisionedStorageInMB": 336118, + "RecoverySite": { + "href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3", + "identifier": "057cab27-f02a-443a-989d-7f14341fa9c3", + "rel": null, + "type": "PeerSiteApi" + }, + "ServiceProfile": null, + "ServiceProfileIdentifier": null, + "ServiceProfileName": "", + "SourceSite": "WCHL - NC", + "Status": 1, + "SubStatus": 0, + "TargetSite": "WCHL - CA", + "ThroughputInMB": 0.27197265625, + "UsedStorageInMB": 245465, + "VmsCount": 4, + "VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd", + "VpgName": "ExportStuff", + "Zorg": { + "href": "https://192.168.10.20:9669/v1/zorgs/00000000-0000-0000-0000-000000000000", + "identifier": "00000000-0000-0000-0000-000000000000", + "rel": null, + "type": "ZorgApi" + } +} diff --git a/Tests/Public/Mocks/LocalSiteInfo.json b/Tests/Public/Mocks/LocalSiteInfo.json new file mode 100644 index 0000000..8fe97a2 --- /dev/null +++ b/Tests/Public/Mocks/LocalSiteInfo.json @@ -0,0 +1,20 @@ +{ + "BandwidthThrottlingInMBs": -1, + "ContactEmail": "vSphere-Site01@zerto.com", + "ContactName": "vSphere-Site01@zerto.com", + "ContactPhone": "066-6666666", + "IpAddress": "192.168.200.1", + "IsReplicationToSelfEnabled": true, + "Link": { + "href": "https://192.168.222.1:7669/v1/localsite", + "identifier": "63a62dc2-ef6f-45aa-809f-9dbaeb8c06cf", + "rel": null, + "type": "LocalSiteApi" + }, + "Location": "vSphere-Site01", + "SiteIdentifier": "63a62dc2-ef6f-45aa-809f-9dbaeb8c06cf", + "SiteName": "vSphere-Site01 at Zerto", + "SiteType": "VCenter", + "UtcOffsetInMinutes": -240, + "Version": "7.0.0" +} diff --git a/Tests/Public/Mocks/PairingToken.json b/Tests/Public/Mocks/PairingToken.json new file mode 100644 index 0000000..1b34001 --- /dev/null +++ b/Tests/Public/Mocks/PairingToken.json @@ -0,0 +1,4 @@ +{ + "Token": "TH15ISN0T4R3AL70KEN", + "UtcExpirationDate": "10/09/2019 12:55 PM" +} diff --git a/Tests/Public/Mocks/ProtectedVms.json b/Tests/Public/Mocks/ProtectedVms.json new file mode 100644 index 0000000..8326055 --- /dev/null +++ b/Tests/Public/Mocks/ProtectedVms.json @@ -0,0 +1,274 @@ +[ + { + "ActualRPO": 7, + "EnabledActions": { + "IsFlrEnabled": true + }, + "Entities": { + "Protected": 0, + "Recovery": 0, + "Source": 0, + "Target": 0 + }, + "HardwareVersion": "vmx-15", + "IOPs": 2, + "IsVmExists": true, + "JournalHardLimit": { + "LimitType": 1, + "LimitValue": 153600 + }, + "JournalUsedStorageMb": 640, + "JournalWarningThreshold": { + "LimitType": 1, + "LimitValue": 115200 + }, + "LastTest": null, + "Link": { + "href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": null, + "type": "VmApi" + }, + "Link_{0}": { + "href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": "self", + "type": "VmApi" + }, + "OrganizationName": "", + "OutgoingBandWidthInMbps": 0.001953125, + "Priority": 1, + "ProtectedSite": { + "href": "https://192.168.10.20:9669/v1/localsite", + "identifier": "9e09efa0-0d00-46ed-929b-f86273b28205", + "rel": null, + "type": "LocalSiteApi" + }, + "ProvisionedStorageInMB": 77906, + "RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15", + "RecoverySite": { + "href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3", + "identifier": "057cab27-f02a-443a-989d-7f14341fa9c3", + "rel": null, + "type": "PeerSiteApi" + }, + "SourceSite": "WCHL - NC", + "Status": 1, + "SubStatus": 0, + "TargetSite": "WCHL - CA", + "ThroughputInMB": 0, + "UsedStorageInMB": 77906, + "VmIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38", + "VmName": "ncesx3.nc.lab", + "Volumes": [ + { + "VmVolumeIdentifier": "scsi:0:0" + } + ], + "VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd", + "VpgName": "ExportStuff" + }, + { + "ActualRPO": 7, + "EnabledActions": { + "IsFlrEnabled": true + }, + "Entities": { + "Protected": 0, + "Recovery": 0, + "Source": 0, + "Target": 0 + }, + "HardwareVersion": "vmx-15", + "IOPs": 1, + "IsVmExists": true, + "JournalHardLimit": { + "LimitType": 1, + "LimitValue": 153600 + }, + "JournalUsedStorageMb": 609, + "JournalWarningThreshold": { + "LimitType": 1, + "LimitValue": 115200 + }, + "LastTest": null, + "Link": { + "href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": null, + "type": "VmApi" + }, + "Link_{0}": { + "href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": "self", + "type": "VmApi" + }, + "OrganizationName": "", + "OutgoingBandWidthInMbps": 0.0009765625, + "Priority": 1, + "ProtectedSite": { + "href": "https://192.168.10.20:9669/v1/localsite", + "identifier": "9e09efa0-0d00-46ed-929b-f86273b28205", + "rel": null, + "type": "LocalSiteApi" + }, + "ProvisionedStorageInMB": 77906, + "RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15", + "RecoverySite": { + "href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3", + "identifier": "057cab27-f02a-443a-989d-7f14341fa9c3", + "rel": null, + "type": "PeerSiteApi" + }, + "SourceSite": "WCHL - NC", + "Status": 1, + "SubStatus": 0, + "TargetSite": "WCHL - CA", + "ThroughputInMB": 0, + "UsedStorageInMB": 77906, + "VmIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37", + "VmName": "ncesx2.nc.lab", + "Volumes": [ + { + "VmVolumeIdentifier": "scsi:0:0" + } + ], + "VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd", + "VpgName": "ExportStuff" + }, + { + "ActualRPO": 7, + "EnabledActions": { + "IsFlrEnabled": true + }, + "Entities": { + "Protected": 0, + "Recovery": 0, + "Source": 0, + "Target": 0 + }, + "HardwareVersion": "vmx-15", + "IOPs": 2, + "IsVmExists": true, + "JournalHardLimit": { + "LimitType": 1, + "LimitValue": 153600 + }, + "JournalUsedStorageMb": 634, + "JournalWarningThreshold": { + "LimitType": 1, + "LimitValue": 115200 + }, + "LastTest": null, + "Link": { + "href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": null, + "type": "VmApi" + }, + "Link_{0}": { + "href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": "self", + "type": "VmApi" + }, + "OrganizationName": "", + "OutgoingBandWidthInMbps": 0.00146484375, + "Priority": 1, + "ProtectedSite": { + "href": "https://192.168.10.20:9669/v1/localsite", + "identifier": "9e09efa0-0d00-46ed-929b-f86273b28205", + "rel": null, + "type": "LocalSiteApi" + }, + "ProvisionedStorageInMB": 77906, + "RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15", + "RecoverySite": { + "href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3", + "identifier": "057cab27-f02a-443a-989d-7f14341fa9c3", + "rel": null, + "type": "PeerSiteApi" + }, + "SourceSite": "WCHL - NC", + "Status": 1, + "SubStatus": 0, + "TargetSite": "WCHL - CA", + "ThroughputInMB": 0, + "UsedStorageInMB": 77906, + "VmIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36", + "VmName": "ncesx1.nc.lab", + "Volumes": [ + { + "VmVolumeIdentifier": "scsi:0:0" + } + ], + "VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd", + "VpgName": "ExportStuff" + }, + { + "ActualRPO": 7, + "EnabledActions": { + "IsFlrEnabled": true + }, + "Entities": { + "Protected": 0, + "Recovery": 0, + "Source": 0, + "Target": 0 + }, + "HardwareVersion": "vmx-14", + "IOPs": 5, + "IsVmExists": true, + "JournalHardLimit": { + "LimitType": 1, + "LimitValue": 153600 + }, + "JournalUsedStorageMb": 642, + "JournalWarningThreshold": { + "LimitType": 1, + "LimitValue": 115200 + }, + "LastTest": null, + "Link": { + "href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": null, + "type": "VmApi" + }, + "Link_{0}": { + "href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd", + "rel": "self", + "type": "VmApi" + }, + "OrganizationName": "", + "OutgoingBandWidthInMbps": 0.01953125, + "Priority": 1, + "ProtectedSite": { + "href": "https://192.168.10.20:9669/v1/localsite", + "identifier": "9e09efa0-0d00-46ed-929b-f86273b28205", + "rel": null, + "type": "LocalSiteApi" + }, + "ProvisionedStorageInMB": 102400, + "RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15", + "RecoverySite": { + "href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3", + "identifier": "057cab27-f02a-443a-989d-7f14341fa9c3", + "rel": null, + "type": "PeerSiteApi" + }, + "SourceSite": "WCHL - NC", + "Status": 1, + "SubStatus": 0, + "TargetSite": "WCHL - CA", + "ThroughputInMB": 0, + "UsedStorageInMB": 11747, + "VmIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26", + "VmName": "nczvm.nc.lab", + "Volumes": [ + { + "VmVolumeIdentifier": "scsi:0:0" + } + ], + "VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd", + "VpgName": "ExportStuff" + } +] diff --git a/Tests/Public/Mocks/TaskId.txt b/Tests/Public/Mocks/TaskId.txt new file mode 100644 index 0000000..6c7b99c --- /dev/null +++ b/Tests/Public/Mocks/TaskId.txt @@ -0,0 +1 @@ +7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a diff --git a/Tests/Public/Mocks/UnprotectedVms.json b/Tests/Public/Mocks/UnprotectedVms.json new file mode 100644 index 0000000..985c8fb --- /dev/null +++ b/Tests/Public/Mocks/UnprotectedVms.json @@ -0,0 +1,18 @@ +[ + { + "VmIdentifier": "d809de8e-deb7-45cc-b620-08030a1143e1.vm-87", + "VmName": "sql01-prod" + }, + { + "VmIdentifier": "d809de8e-deb7-45cc-b620-08030a1143e1.vm-34", + "VmName": "Ubuntu01" + }, + { + "VmIdentifier": "d809de8e-deb7-45cc-b620-08030a1143e1.vm-79", + "VmName": "Win2019Template" + }, + { + "VmIdentifier": "d809de8e-deb7-45cc-b620-08030a1143e1.vm-25", + "VmName": "WinTemplate" + } +] diff --git a/Tests/Public/Mocks/VPGInfo.json b/Tests/Public/Mocks/VPGInfo.json new file mode 100644 index 0000000..f2fae5e --- /dev/null +++ b/Tests/Public/Mocks/VPGInfo.json @@ -0,0 +1,75 @@ +{ + "ActiveProcessesApi": { + "RunningFailOverTestApi": null + }, + "ActualRPO": 6, + "BackupEnabled": false, + "ConfiguredRpoSeconds": 300, + "Entities": { + "Protected": 0, + "Recovery": 0, + "Source": 0, + "Target": 0 + }, + "FailSafeHistory": { + "ActualFailSafeHistory": 60, + "ConfiguredFailSafeHistory": 60, + "FailSafeDescription": "" + }, + "HistoryStatusApi": { + "ActualHistoryInMinutes": 225, + "ConfiguredHistoryInMinutes": 60, + "EarliestCheckpoint": { + "CheckpointIdentifier": "166834", + "Tag": null, + "TimeStamp": "2019-07-11T13:47:23Z" + } + }, + "IOPs": 8, + "LastTest": "2019-07-11T16:51:07.022Z", + "Link": { + "href": "https://192.168.222.1:7669/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9", + "identifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9", + "rel": null, + "type": "VpgApi" + }, + "Link_{0}": { + "href": "https://192.168.222.1:7669/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9", + "rel": "self", + "type": "VpgApi" + }, + "OrganizationName": "", + "Priority": 1, + "ProgressPercentage": 0, + "ProtectedSite": { + "href": "https://192.168.222.1:7669/v1/localsite", + "identifier": "63a62dc2-ef6f-45aa-809f-9dbaeb8c06cf", + "rel": null, + "type": "LocalSiteApi" + }, + "ProvisionedStorageInMB": 400, + "RecoverySite": { + "href": "https://192.168.222.1:7669/v1/peersites/3e4cdd0d-1064-4022-921f-6265ad6d335a", + "identifier": "3e4cdd0d-1064-4022-921f-6265ad6d335a", + "rel": null, + "type": "PeerSiteApi" + }, + "ServiceProfile": null, + "ServiceProfileIdentifier": null, + "ServiceProfileName": "", + "SourceSite": "vSphere-Site01 at Zerto", + "Status": 1, + "SubStatus": 0, + "TargetSite": "vSphere-Site02 at Zerto", + "ThroughputInMB": 58.55859375, + "UsedStorageInMB": 400, + "VmsCount": 4, + "VpgIdentifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9", + "VpgName": "Exchange", + "Zorg": { + "href": "https://192.168.222.1:7669/v1/zorgs/00000000-0000-0000-0000-000000000000", + "identifier": "00000000-0000-0000-0000-000000000000", + "rel": null, + "type": "ZorgApi" + } +} diff --git a/Tests/Public/Mocks/VirtualSite-Folders.json b/Tests/Public/Mocks/VirtualSite-Folders.json new file mode 100644 index 0000000..c14eb73 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-Folders.json @@ -0,0 +1,14 @@ +[ + { + "FolderIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.group-v3", + "FolderName": "/" + }, + { + "FolderIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.group-v27", + "FolderName": "Templates" + }, + { + "FolderIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.group-v9", + "FolderName": "Discovered virtual machine" + } +] diff --git a/Tests/Public/Mocks/VirtualSite-Networks.json b/Tests/Public/Mocks/VirtualSite-Networks.json new file mode 100644 index 0000000..3c08c27 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-Networks.json @@ -0,0 +1,4 @@ +{ + "NetworkIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.network-20", + "VirtualizationNetworkName": "VM Network" +} diff --git a/Tests/Public/Mocks/VirtualSite-NoParams.json b/Tests/Public/Mocks/VirtualSite-NoParams.json new file mode 100644 index 0000000..feccaa9 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-NoParams.json @@ -0,0 +1,10 @@ +[ + { + "SiteIdentifier": "8e1c9f53-4973-4a4a-b2dd-1ebb293614d8", + "VirtualizationSiteName": "cavc.nc.lab" + }, + { + "SiteIdentifier": "15aa0d43-69cd-400a-8b99-fe94bbac3e19", + "VirtualizationSiteName": "ncvc.nc.lab" + } +] diff --git a/Tests/Public/Mocks/VirtualSite-ResourcePools.json b/Tests/Public/Mocks/VirtualSite-ResourcePools.json new file mode 100644 index 0000000..7d65eff --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-ResourcePools.json @@ -0,0 +1,4 @@ +{ + "ResourcePoolIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.resgroup-8", + "ResourcepoolName": "Resources" +} diff --git a/Tests/Public/Mocks/VirtualSite-SiteId.json b/Tests/Public/Mocks/VirtualSite-SiteId.json new file mode 100644 index 0000000..4abdcc3 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-SiteId.json @@ -0,0 +1,4 @@ +{ + "SiteIdentifier": "8e1c9f53-4973-4a4a-b2dd-1ebb293614d8", + "VirtualizationSiteName": "cavc.nc.lab" +} diff --git a/Tests/Public/Mocks/VirtualSite-VMs.json b/Tests/Public/Mocks/VirtualSite-VMs.json new file mode 100644 index 0000000..6debd36 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-VMs.json @@ -0,0 +1,18 @@ +[ + { + "VmIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.vm-55", + "VmName": "TimeSeries" + }, + { + "VmIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.vm-53", + "VmName": "AnsibleTarget" + }, + { + "VmIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.vm-28", + "VmName": "cazvm.nc.lab" + }, + { + "VmIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.vm-26", + "VmName": "WinTemplate" + } +] diff --git a/Tests/Public/Mocks/VirtualSite-datastoreClusters.json b/Tests/Public/Mocks/VirtualSite-datastoreClusters.json new file mode 100644 index 0000000..82a0a11 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-datastoreClusters.json @@ -0,0 +1,4 @@ +{ + "DatastoreClusterIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.group-p44", + "DatastoreClusterName": "CA_DS_Cluster" +} diff --git a/Tests/Public/Mocks/VirtualSite-datastores.json b/Tests/Public/Mocks/VirtualSite-datastores.json new file mode 100644 index 0000000..0bdbc15 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-datastores.json @@ -0,0 +1,34 @@ +[ + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-40", + "DatastoreName": "MgmtLUN" + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-23", + "DatastoreName": "LabPool" + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-22", + "DatastoreName": "datastore1 (2)" + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-21", + "DatastoreName": "datastore1 (1)" + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-19", + "DatastoreName": "datastore1" + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-41", + "DatastoreName": "CA_DS_01" + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-42", + "DatastoreName": "CA_DS_02" + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-43", + "DatastoreName": "CA_DS_03" + } +] diff --git a/Tests/Public/Mocks/VirtualSite-devices-hostid.json b/Tests/Public/Mocks/VirtualSite-devices-hostid.json new file mode 100644 index 0000000..f2768c4 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-devices-hostid.json @@ -0,0 +1,62 @@ +[ + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-40", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.naa.6001405a18009ded4f84d4177d8893d6", + "DeviceName": "SYNOLOGY iSCSI Disk (naa.6001405a18009ded4f84d4177d8893d6)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 1073741824000, + "VmIdentifier": null + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-22", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.mpx.vmhba1:C0:T0:L0", + "DeviceName": "Local VMware Disk (mpx.vmhba1:C0:T0:L0)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 42949672960, + "VmIdentifier": null + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-42", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.naa.6001405922cd662dc343d4683d9aecd1", + "DeviceName": "SYNOLOGY iSCSI Disk (naa.6001405922cd662dc343d4683d9aecd1)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 536870912000, + "VmIdentifier": null + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-41", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.naa.6001405522c4ad5d65a6d4113d9657dc", + "DeviceName": "SYNOLOGY iSCSI Disk (naa.6001405522c4ad5d65a6d4113d9657dc)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 536870912000, + "VmIdentifier": null + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-43", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.naa.600140533d732abd8caed42cfda50ed1", + "DeviceName": "SYNOLOGY iSCSI Disk (naa.600140533d732abd8caed42cfda50ed1)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 536870912000, + "VmIdentifier": null + } +] diff --git a/Tests/Public/Mocks/VirtualSite-devices.json b/Tests/Public/Mocks/VirtualSite-devices.json new file mode 100644 index 0000000..f2768c4 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-devices.json @@ -0,0 +1,62 @@ +[ + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-40", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.naa.6001405a18009ded4f84d4177d8893d6", + "DeviceName": "SYNOLOGY iSCSI Disk (naa.6001405a18009ded4f84d4177d8893d6)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 1073741824000, + "VmIdentifier": null + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-22", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.mpx.vmhba1:C0:T0:L0", + "DeviceName": "Local VMware Disk (mpx.vmhba1:C0:T0:L0)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 42949672960, + "VmIdentifier": null + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-42", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.naa.6001405922cd662dc343d4683d9aecd1", + "DeviceName": "SYNOLOGY iSCSI Disk (naa.6001405922cd662dc343d4683d9aecd1)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 536870912000, + "VmIdentifier": null + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-41", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.naa.6001405522c4ad5d65a6d4113d9657dc", + "DeviceName": "SYNOLOGY iSCSI Disk (naa.6001405522c4ad5d65a6d4113d9657dc)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 536870912000, + "VmIdentifier": null + }, + { + "DatastoreIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.datastore-43", + "DeviceIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.naa.600140533d732abd8caed42cfda50ed1", + "DeviceName": "SYNOLOGY iSCSI Disk (naa.600140533d732abd8caed42cfda50ed1)", + "HostIdentifiers": [ + "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "09db6c5b-b956-430f-9589-b58876ca377a.host-12" + ], + "SizeInBytes": 536870912000, + "VmIdentifier": null + } +] diff --git a/Tests/Public/Mocks/VirtualSite-hostClusters.json b/Tests/Public/Mocks/VirtualSite-hostClusters.json new file mode 100644 index 0000000..2a28338 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-hostClusters.json @@ -0,0 +1,4 @@ +{ + "ClusterIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.domain-c7", + "VirtualizationClusterName": "CA Cluster" +} diff --git a/Tests/Public/Mocks/VirtualSite-hosts-hostid.json b/Tests/Public/Mocks/VirtualSite-hosts-hostid.json new file mode 100644 index 0000000..7a74266 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-hosts-hostid.json @@ -0,0 +1,4 @@ +{ + "HostIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "VirtualizationHostName": "caesx3.nc.lab" +} diff --git a/Tests/Public/Mocks/VirtualSite-hosts.json b/Tests/Public/Mocks/VirtualSite-hosts.json new file mode 100644 index 0000000..8f0ba82 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-hosts.json @@ -0,0 +1,14 @@ +[ + { + "HostIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.host-18", + "VirtualizationHostName": "caesx3.nc.lab" + }, + { + "HostIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.host-15", + "VirtualizationHostName": "caesx2.nc.lab" + }, + { + "HostIdentifier": "09db6c5b-b956-430f-9589-b58876ca377a.host-12", + "VirtualizationHostName": "caesx1.nc.lab" + } +] diff --git a/Tests/Public/Mocks/VirtualSite-repositories.json b/Tests/Public/Mocks/VirtualSite-repositories.json new file mode 100644 index 0000000..95b7921 --- /dev/null +++ b/Tests/Public/Mocks/VirtualSite-repositories.json @@ -0,0 +1,7 @@ +{ + "ConnectionType": "ServerMessageBlock", + "Path": "\\\\192.168.1.150\\zBackups", + "RepositoryIdentifier": "120355ce-fcd0-4820-a971-787d0470793b", + "RepositoryName": "Synology", + "StorageType": "NetworkShare" +} diff --git a/Tests/Public/Mocks/VpgId.txt b/Tests/Public/Mocks/VpgId.txt new file mode 100644 index 0000000..d6714d6 --- /dev/null +++ b/Tests/Public/Mocks/VpgId.txt @@ -0,0 +1 @@ +9607f923-00a7-477b-8b04-26a386214455 diff --git a/Tests/Public/Mocks/ZAToken.json b/Tests/Public/Mocks/ZAToken.json new file mode 100644 index 0000000..335aa89 --- /dev/null +++ b/Tests/Public/Mocks/ZAToken.json @@ -0,0 +1,4 @@ +{ + "type": "Bearer", + "token": "N074r34l70k3n" +} diff --git a/Tests/Public/New-ZertoPairingToken.Tests.ps1 b/Tests/Public/New-ZertoPairingToken.Tests.ps1 new file mode 100644 index 0000000..8d69a2c --- /dev/null +++ b/Tests/Public/New-ZertoPairingToken.Tests.ps1 @@ -0,0 +1,51 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock + } + + Context "$global:function::Parameter Unit Tests" { + It "$global:function should have exactly 13 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 13 + } + + It "Supports 'SupportsShouldProcess'" { + Get-Command $global:function | Should -HaveParameter WhatIf + Get-Command $global:function | Should -HaveParameter Confirm + $script:ScriptBlock | Should -match 'SupportsShouldProcess' + $script:ScriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + } + + Context "$global:function::Parameter Functional Tests" { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { + return (Get-Content -Raw "$global:here\Mocks\PairingToken.json" | ConvertFrom-Json) + } + + It "Returns a Token" { + $Token = New-ZertoPairingToken + $Token | Should -Not -Be $Null + $Token.Token | Should -Be "TH15ISN0T4R3AL70KEN" + } + + It "Returns a ExpirationDate" { + $Token = New-ZertoPairingToken + $Token | Should -Not -Be $Null + $Token.UtcExpirationDate | Should -Be "10/09/2019 12:55 PM" + } + + It "Does not return a taskId if '-whatif' is used" { + $results = New-ZertoPairingToken -WhatIf + $results | Should -BeNullOrEmpty + } + + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 2 + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/New-ZertoVpg.Tests.ps1 b/Tests/Public/New-ZertoVpg.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/New-ZertoVpg.Tests.ps1 +++ b/Tests/Public/New-ZertoVpg.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 b/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 +++ b/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 b/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Remove-ZertoVpg.Tests.ps1 b/Tests/Public/Remove-ZertoVpg.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Remove-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Remove-ZertoVpg.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Remove-ZertoVpgSettingsIdentifier.Tests.ps1 b/Tests/Public/Remove-ZertoVpgSettingsIdentifier.Tests.ps1 new file mode 100644 index 0000000..770482b --- /dev/null +++ b/Tests/Public/Remove-ZertoVpgSettingsIdentifier.Tests.ps1 @@ -0,0 +1,17 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { + + } + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Remove-ZertoVpgVm.Tests.ps1 b/Tests/Public/Remove-ZertoVpgVm.Tests.ps1 new file mode 100644 index 0000000..12d2860 --- /dev/null +++ b/Tests/Public/Remove-ZertoVpgVm.Tests.ps1 @@ -0,0 +1,52 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -Leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock + } + + Context "$global:function::Parameter Unit Tests" { + + It "$global:function should have exactly 15 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 15 + } + + $ParameterTestCases = @( + @{ParameterName = 'Vm'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + @{ParameterName = 'VpgName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It " parameter has correct validation setting" -TestCases $ParameterTestCases { + param($ParameterName, $Validation) + Switch ($Validation) { + 'NotNullOrEmpty' { + $attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes + $attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1 + } + + default { + $true | Should -Be $false -Because "No Validation Selected. Review test cases" + } + } + } + + It "Supports 'SupportsShouldProcess'" { + Get-Command $global:function | Should -HaveParameter WhatIf + Get-Command $global:function | Should -HaveParameter Confirm + $script:ScriptBlock | Should -Match 'SupportsShouldProcess' + $script:ScriptBlock | Should -Match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + } + + Context "Add-ZertoPeerSite::Functional Unit Tests" { + } +} +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Resume-ZertoVpg.Tests.ps1 b/Tests/Public/Resume-ZertoVpg.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Resume-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Resume-ZertoVpg.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 b/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 +++ b/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Set-ZertoAlert.Tests.ps1 b/Tests/Public/Set-ZertoAlert.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Set-ZertoAlert.Tests.ps1 +++ b/Tests/Public/Set-ZertoAlert.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Set-ZertoLicense.Tests.ps1 b/Tests/Public/Set-ZertoLicense.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Set-ZertoLicense.Tests.ps1 +++ b/Tests/Public/Set-ZertoLicense.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Set-ZertoUserCredential.Tests.ps1 b/Tests/Public/Set-ZertoUserCredential.Tests.ps1 new file mode 100644 index 0000000..74cc8ac --- /dev/null +++ b/Tests/Public/Set-ZertoUserCredential.Tests.ps1 @@ -0,0 +1,42 @@ +#Requires -Modules Pester +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] + +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + InModuleScope -ModuleName ZertoApiWrapper { + + Context "$global:function::Parameter Unit Tests" { + + BeforeAll { + $script:ScriptBlock = (Get-Command $global:function).ScriptBlock + } + + It "$global:function should have exactly 14 parameters defined" { + (Get-Command $global:function).Parameters.Count | Should -Be 14 + } + + $ParameterTestCases = @( + @{ParameterName = 'UserCredential'; Type = 'pscredential'; Mandatory = $true } + ) + + It " parameter is of type" -TestCases $ParameterTestCases { + param($ParameterName, $Type, $Mandatory, $Validation) + Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type + } + + It "Supports 'SupportsShouldProcess'" { + Get-Command $global:function | Should -HaveParameter WhatIf + Get-Command $global:function | Should -HaveParameter Confirm + $script:ScriptBlock | Should -match 'SupportsShouldProcess' + $script:ScriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)' + } + } + + Context "$global:function::Parameter Functional Tests" { + + } + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Start-ZertoCloneVpg.Tests.ps1 b/Tests/Public/Start-ZertoCloneVpg.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Start-ZertoCloneVpg.Tests.ps1 +++ b/Tests/Public/Start-ZertoCloneVpg.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Start-ZertoFailoverTest.Tests.ps1 b/Tests/Public/Start-ZertoFailoverTest.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Start-ZertoFailoverTest.Tests.ps1 +++ b/Tests/Public/Start-ZertoFailoverTest.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Stop-ZertoCloneVpg.Tests.ps1 b/Tests/Public/Stop-ZertoCloneVpg.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Stop-ZertoCloneVpg.Tests.ps1 +++ b/Tests/Public/Stop-ZertoCloneVpg.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Stop-ZertoFailoverTest.Tests.ps1 b/Tests/Public/Stop-ZertoFailoverTest.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Stop-ZertoFailoverTest.Tests.ps1 +++ b/Tests/Public/Stop-ZertoFailoverTest.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Suspend-ZertoVpg.Tests.ps1 b/Tests/Public/Suspend-ZertoVpg.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Suspend-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Suspend-ZertoVpg.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/Public/Uninstall-ZertoVra.Tests.ps1 b/Tests/Public/Uninstall-ZertoVra.Tests.ps1 index 50d2f9d..770482b 100644 --- a/Tests/Public/Uninstall-ZertoVra.Tests.ps1 +++ b/Tests/Public/Uninstall-ZertoVra.Tests.ps1 @@ -1,19 +1,17 @@ #Requires -Modules Pester -$moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") -$file = Get-ChildItem "$here\$sut" -$modulePath = $here -replace "Public", "" -$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" -Get-Module -Name ZertoApiWrapper | Remove-Module -Force -Import-Module $moduleFile -Force +$global:here = (Split-Path -Parent $PSCommandPath) +$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0] -Describe $file.BaseName -Tag 'Unit' { +Describe $global:function -Tag 'Unit', 'Source', 'Built' { + + Context "$global:function::Parameter Unit Tests" { - It "is valid Powershell (Has no script errors)" { - $contents = Get-Content -Path $file -ErrorAction Stop - $errors = $null - $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) - $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$global:function::Parameter Functional Tests" { + + } +} + +Remove-Variable -Name here -Scope Global +Remove-Variable -Name function -Scope Global diff --git a/Tests/ZertoApiWrapper.Tests.ps1 b/Tests/ZertoApiWrapper.Tests.ps1 index bcbb9ca..0f398ae 100644 --- a/Tests/ZertoApiWrapper.Tests.ps1 +++ b/Tests/ZertoApiWrapper.Tests.ps1 @@ -1,5 +1,5 @@ #Requires -Modules Pester -$testPath = Split-Path -Parent $MyInvocation.MyCommand.Path +$testPath = Split-Path -Parent $PSCommandPath $docsPath = $testPath -replace 'Tests', 'docs' $modulePath = $testPath -replace 'Tests', 'ZertoApiWrapper' $module = Split-Path -Leaf $modulePath @@ -9,7 +9,7 @@ Describe "Module: $module" -Tags 'Unit' { Context "Module Configuration" { It "Has a root module file ($module.psm1)" { - "$modulePath\$module.psm1" | should -Exist + "$modulePath\$module.psm1" | Should -Exist } It "Is valid Powershell (Has no script errors)" { @@ -75,20 +75,20 @@ Describe "Module: $module" -Tags 'Unit' { $externalHelpFile | Should -Exist } - it "External Help file does not contain place holder values" { - $stubExist = Get-Content -Path $externalHelpFile | Where-Object {$_.Trim() -like '*{{*}}*'} + It "External Help file does not contain place holder values" { + $stubExist = Get-Content -Path $externalHelpFile | Where-Object { $_.Trim() -like '*{{*}}*' } if ($stubExist) { Write-Warning "Found a stub in the Markdown File $externalHelpFile" Write-Warning "$stubExist" } - $stubExist | should benullorempty + $stubExist | Should benullorempty } } It "Is an advanced function" { - $Function.FullName | should -FileContentMatch 'function' - $Function.FullName | should -FileContentMatch 'cmdletbinding' - $Function.FullName | should -FileContentMatch 'param' + $Function.FullName | Should -FileContentMatch 'function' + $Function.FullName | Should -FileContentMatch 'cmdletbinding' + $Function.FullName | Should -FileContentMatch 'param' } It "Is valid Powershell (Has no script errors)" { @@ -97,15 +97,15 @@ Describe "Module: $module" -Tags 'Unit' { $errors | Should -HaveCount 0 } - it "Has openbraces on the same line as the statement" { - $openingBracesExist = $contents | Where-Object {$_.Trim() -eq '{'} + It "Has openbraces on the same line as the statement" { + $openingBracesExist = $contents | Where-Object { $_.Trim() -eq '{' } if ($openingBracesExist) { Write-Warning "Found the following opening brances on their own line:" foreach ($openingBrace in $openingBracesExist) { Write-Warning "Opening Brace on it's own line - $openingBrace" } } - $openingBracesExist | should -BeNullOrEmpty + $openingBracesExist | Should -BeNullOrEmpty } } } diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 index 196f108..e3f8356 100644 --- a/ZertoApiWrapper.Depend.psd1 +++ b/ZertoApiWrapper.Depend.psd1 @@ -7,7 +7,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '5.5.1' + Version = '5.6.0' Tags = 'Bootstrap' } @@ -19,7 +19,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '4.7.3' + Version = '4.10.1' Tags = 'Bootstrap' } @@ -31,7 +31,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '1.18.0' + Version = '1.19.0' Tags = 'Bootstrap' } diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 9a9ad17..08efbac 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,16 +1,28 @@ #Requires -Modules 'InvokeBuild' -. '.\ZertoApiWrapper.settings.ps1' -# import-module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -Verbose -Force +$version = "{0}" -f $(Get-Content .\version.txt) +$moduleOutPath = "{0}\publish\ZertoApiWrapper" -f $BuildRoot -<# [CmdletBinding()] -param([switch]$Install, - [string]$Configuration = (property Configuration Release)) -$targetDir = "temp/$Configuration/ZertoApiWrapper" #> -$version = "{0}.{1}" -f $(Get-Content .\version.txt), $(get-date -format 'yyyyMMdd') +#Define the default task +task . build -task . CreateArtifacts +#Region - Helper Functions +function ImportSourceModule { + If (Get-Module -Name ZertoApiWrapper) { + Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop + } + Import-Module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -ErrorAction Stop +} +function ImportBuiltModule { + If (Get-Module -Name ZertoApiWrapper) { + Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop + } + Import-Module ("{0}\ZertoApiWrapper.psd1" -f $moduleOutPath) -ErrorAction Stop +} +#EndRegion + +#Region - Module Checks <# Synopsis: Ensure platyPS is installed #> task CheckPlatyPSInstalled { if ($null -eq (Get-Module -List platyPS)) { @@ -20,9 +32,11 @@ task CheckPlatyPSInstalled { <# Synopsis: Ensure Pester is installed #> task CheckPesterInstalled { + Get-Module -Name Pester | Remove-Module -Force if ($null -eq (Get-Module -List Pester)) { - Install-Module -Scope CurrentUser -Repository PSGallery -Name Pester + Install-Module -Scope CurrentUser -Repository PSGallery -Name Pester -MaximumVersion 4.99 } + Import-Module -Name Pester -MaximumVersion 4.99 -Force } <# Synopsis: Ensure PSScriptAnalyzer is installed #> @@ -31,7 +45,9 @@ task CheckPSScriptAnalyzerInstalled { Install-Module -Scope CurrentUser -Repository PSGallery -Name PSScriptAnalyzer } } +#EndRegion +#Region - PSSA Tasks <# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #> task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { $scriptAnalyzerParams = @{ @@ -39,7 +55,7 @@ task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest') + ExcludeRule = @('PSUseToExportFieldsInManifest', 'PSUseBOMForUnicodeEncodedFile', 'PSUseSingularNouns', 'PSReviewUnusedParameter') } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams if ($saResults) { @@ -50,11 +66,11 @@ task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { $scriptAnalyzerParams = @{ - Path = "$BuildRoot\temp\" + Path = $moduleOutPath Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = @() + ExcludeRule = @('PSUseSingularNouns', 'PSUseBOMForUnicodeEncodedFile', 'PSReviewUnusedParameter') } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams @@ -63,17 +79,41 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { throw "One or more PSScriptAnalyzer errors/warnings were found" } } +#EndRegion -task FileTests CheckPesterInstalled, { - $testResultsFile = "$BuildRoot\Tests\TestResults.xml" - $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru +#Region - Clean Operations +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 + +#Region - Pester Tests +task SourceFileTests CheckPesterInstalled, { + ImportSourceModule + $testResultsFile = "$BuildRoot\Tests\SourceTestResults.xml" + $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount - assert ($results.FailedCount -eq 0) $FailureMessage + Assert ($results.FailedCount -eq 0) $FailureMessage } +task BuiltFileTests CreatePsm1ForRelease, CheckPesterInstalled, { + ImportBuiltModule + $testResultsFile = "$BuildRoot\Tests\BuiltTestResults.xml" + $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 +} +#EndRegion + +#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, { @@ -83,28 +123,29 @@ task BuildMamlHelp CheckPlatyPSInstalled, { platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs } -task UpdateMarkdownHelp CheckPlatyPSInstalled, { - remove-module ZertoApiWrapper -force -ErrorAction SilentlyContinue - Import-Module .\ZertoApiWrapper\ZertoApiWrapper.psm1 -Force - Update-MarkDownHelp -Path docs -AlphabeticParamsOrder +task UpdateMarkdownHelp quickBuild, CheckPlatyPSInstalled, { + ImportBuiltModule + Update-MarkdownHelpModule -Path docs -AlphabeticParamsOrder } +#EndRegion -task CreatePsd1ForRelease CleanTemp, { +#Region - Build Module Files +task CreatePsd1ForRelease CleanPublish, { $functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName } - $releaseNotes = "# {0}{1}" -f $version, $(Get-Content .\RELEASENOTES.md -Raw) + $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' Author = 'Wes Carroll' CompanyName = 'Zerto' - Copyright = '(c) {0} Wes Carroll. All rights reserved.' -f $(Get-Date -format 'yyyy') - Description = 'PowerShell Core Wrapper Module for Zerto Virtual Manager API' - PowerShellVersion = '6.0.0' - ProjectUri = 'https://github.com/wcarroll/ZertoApiWrapper' - LicenseUri = 'https://github.com/wcarroll/ZertoApiWrapper/blob/master/LICENSE' + Copyright = '(c) {0} Wes Carroll. All rights reserved.' -f $(Get-Date -Format 'yyyy') + Description = 'Windows PowerShell and PowerShell Core API Wrapper Module for Zerto Virtual Manager' + PowerShellVersion = '5.1.0' + ProjectUri = 'https://github.com/ZertoPublic/ZertoApiWrapper' + LicenseUri = 'https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/LICENSE' Tags = @("Zerto", "Automation") FunctionsToExport = $functionsToExport CmdletsToExport = @() @@ -115,67 +156,49 @@ task CreatePsd1ForRelease CleanTemp, { New-ModuleManifest @ManifestParams } -task CleanTemp { - if (-not $(Test-Path "$BuildRoot\temp")) { - New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory" - } - Remove-Item -Recurse -Path "$BuildRoot\temp\*" -} - task CreatePsm1ForRelease CreatePsd1ForRelease, { $emptyLine = "" - $psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1" + $psm1Path = "{0}\ZertoApiWrapper.psm1" -f $moduleOutPath $lines = '#------------------------------------------------------------#' - $Public = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue ) - $functionCount = 0 - $exportString = "" - foreach ($file in $Public) { - if ($functionCount -eq 0) { - $functionCount++ - $exportString = "{0}" -f $file.BaseName - } else { - $functionCount++ - $exportString = "{0}, {1}" -f $exportString, $file.BaseName - } - } - $Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue ) - 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 + $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 -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" } +#EndRegion -task CreateArtifacts CleanPublish, CreateModule, { - if (-not $(Test-Path "$BuildRoot\publish")) { - New-Item -Path $BuildRoot -Name "publish" -ItemType Directory +#Region - Artifacts \ Publish +# 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 } - Compress-Archive -Path .\temp\* -DestinationPath .\publish\ZertoApiWrapper.zip +} +#EndRegion + +task build CleanPublish, CreatePsm1ForRelease, AnalyzeBuiltFiles, BuiltFileTests, CreateArtifacts +task quickBuild CleanPublish, CreatePsm1ForRelease, AnalyzeBuiltFiles, { Get-Module -Name ZertoApiWrapper | Remove-Module -Force - Import-Module .\temp\ZertoApiWrapper.psd1 -Force - (Get-Module ZertoApiWrapper).ReleaseNotes | Add-Content .\publish\release-notes.txt - (Get-Module ZertoApiWrapper).Version.ToString() | Add-Content .\publish\release-version.txt + ImportBuiltModule } - -task CleanPublish { - if ($(Test-Path "$BuildRoot\publish")) { - Remove-Item -Recurse -Path "$BuildRoot\publish\*" - } -} - -task CreateModule CleanTemp, FileTests, AnalyzeBuiltFiles, BuildMamlHelp, { - +task release build, { + Publish-Module -Path $moduleOutPath -NuGetApiKey "1234" -WhatIf } diff --git a/ZertoApiWrapper/Private/Get-Map.ps1 b/ZertoApiWrapper/Private/Get-Map.ps1 new file mode 100644 index 0000000..343a711 --- /dev/null +++ b/ZertoApiWrapper/Private/Get-Map.ps1 @@ -0,0 +1,21 @@ +function Get-Map { + [CmdletBinding()] + [OutputType([Hashtable])] + param( + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [PSCustomObject]$inputObject, + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$key, + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$value + ) + + $returnMap = @{ } + foreach ($item in $inputObject) { + $returnMap[$item.$key] = $item.$value + } + $returnMap +} diff --git a/ZertoApiWrapper/Private/Get-ZertoApiFilter.ps1 b/ZertoApiWrapper/Private/Get-ZertoApiFilter.ps1 index a6400ca..53fbeed 100644 --- a/ZertoApiWrapper/Private/Get-ZertoApiFilter.ps1 +++ b/ZertoApiWrapper/Private/Get-ZertoApiFilter.ps1 @@ -1,22 +1,42 @@ function Get-ZertoApiFilter { [cmdletbinding()] + [Outputtype([String])] param( - [Parameter( Mandatory = $true, + [Parameter( + Mandatory, HelpMessage = "Hashtable that contains filter keys and values" )] + [ValidateNotNullOrEmpty()] [hashtable]$filterTable ) # Define the start of the return string [string]$returnString = "?" - + $commonParameters = @( + "Debug" + "ErrorAction" + "ErrorVariable" + "InformationAction" + "InformationVariable" + "OutVariable" + "OutBuffer" + "PipelineVariable" + "Verbose" + "WarningAction" + "WarningVariable" + "WhatIf" + "Confirm" + ) #Foreach item in the table, process each item foreach ( $key in $filterTable.Keys ) { - #If this is not the first item added to the string, add the ampersand and filter - if ($returnString.Length -gt 1) { - $returnString = "{0}&{1}={2}" -f $returnString, $key, $filterTable[$key] - } else { - #If it is the first item, just add the first item - $returnString = "{0}{1}={2}" -f $returnString, $key, $filterTable[$key] + # If the key is not a common parameter, process it. + if ($key -notin $commonParameters) { + #If this is not the first item added to the string, add the ampersand and filter + if ($returnString.Length -gt 1) { + $returnString = "{0}&{1}={2}" -f $returnString, $key, $filterTable[$key] + } else { + #If it is the first item, just add the first item + $returnString = "{0}{1}={2}" -f $returnString, $key, $filterTable[$key] + } } } # Return the built query String diff --git a/ZertoApiWrapper/Private/Invoke-ZertoRestRequest.ps1 b/ZertoApiWrapper/Private/Invoke-ZertoRestRequest.ps1 deleted file mode 100644 index a52f9a8..0000000 --- a/ZertoApiWrapper/Private/Invoke-ZertoRestRequest.ps1 +++ /dev/null @@ -1,48 +0,0 @@ -function Invoke-ZertoRestRequest { - [cmdletbinding()] - param( - [string]$method = "GET", - [string]$uri, - [string]$apiVersion = "v1", - [string]$body, - [string]$contentType = "application/json", - [System.Management.Automation.PSCredential] - $credential, - [switch]$returnHeaders - ) - $callerErrorActionPreference = $ErrorActionPreference - # If the ZVM server and Port not defined, Stop Call - if ( -not ((Test-Path variable:script:zvmServer) -and (Test-Path variable:script:zvmPort)) ) { - Write-Error -Message "Zerto Connection does not Exist. Please run Connect-ZertoServer first to establish a connection" - break - } - - # 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) ) { - Write-Error -Message "Authorization Token has Expired. Please re-authorize to the Zerto Virtual Manager" - break - } 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 - $apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -SkipCertificateCheck -ResponseHeadersVariable responseHeaders -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 - } - } -} diff --git a/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 index ecf104e..6e1a050 100644 --- a/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 @@ -3,24 +3,33 @@ function Add-ZertoPeerSite { [cmdletbinding( SupportsShouldProcess = $true )] param( [parameter( - Mandatory = $true, + Mandatory, HelpMessage = "Target Hostname or IP address to pair the localsite to." )] - [ValidateScript( {$_ -match [IPAddress]$_ } )] + [ValidateNotNullOrEmpty()] [string]$targetHost, [Parameter( HelpMessage = "Target communication port. Default is 9081" )] [ValidateRange(1024, 65535)] - [int]$targetPort = 9081 + [int]$targetPort = 9081, + [Parameter( + HelpMessage = "The generated token from the destination site. Note: This is only supported when both sites support pairing authentication. This was implemented to support ZVR 7.5 and later." + )] + [ValidateNotNullOrEmpty()] + [string]$token ) begin { - $baseUri = "peersites" - $body = @{"HostName" = $targetHost; "Port" = $targetPort} } process { + $baseUri = "peersites" + if ($PSBoundParameters.Keys.Contains("token")) { + $body = @{ "HostName" = $targetHost; "Port" = $targetPort; "Token" = $token } + } else { + $body = @{ "HostName" = $targetHost; "Port" = $targetPort } + } if ($PSCmdlet.ShouldProcess("Pairing with Site $targetHost")) { Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST" } diff --git a/ZertoApiWrapper/Public/Add-ZertoVpgVm.ps1 b/ZertoApiWrapper/Public/Add-ZertoVpgVm.ps1 new file mode 100644 index 0000000..d504acf --- /dev/null +++ b/ZertoApiWrapper/Public/Add-ZertoVpgVm.ps1 @@ -0,0 +1,104 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Add-ZertoVpgVm { + [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = "VpgName")] + param ( + [Parameter( + Mandatory, + HelpMessage = "Vpg Settings Identifier", + ValueFromPipeline, + ValueFromPipelineByPropertyName, + ValueFromRemainingArguments, + ParameterSetName = "VpgSettingsIdentifier" + )] + [ValidateNotNullOrEmpty()] + [Alias("sid", "settingsIdentifier", "vpgSettingsId")] + [String]$vpgSettingsIdentifier, + [Parameter( + Mandatory, + HelpMessage = "Target VPG Name to Add the VM", + ParameterSetName = "VpgName" + )] + [ValidateNotNullOrEmpty()] + [String]$VpgName, + [Parameter( + Mandatory, + HelpMessage = "Name of VM(s) to add to the VPG" + )] + [ValidateNotNullOrEmpty()] + [String[]]$Vm + ) + + begin { + + } + + process { + if ($PSCmdlet.ParameterSetName -eq "VpgName") { + $VpgIdentifier = Get-ZertoVpg -name $VpgName | Select-Object -ExpandProperty VpgIdentifier + if (-not $VpgIdentifier) { + Write-Error "Unable to find Vpg with name $VpgName. Please check your parameters and try again." -ErrorAction Stop + } else { + $vpgSettingsIdentifier = New-ZertoVpgSettingsIdentifier -vpgIdentifier $VpgIdentifier + } + } + $baseUrl = "vpgsettings/{0}/vms" -f $vpgSettingsIdentifier + $baseSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier + if ($PSCmdlet.ParameterSetName -eq "VpgSettingsIdentifier") { + $VpgName = $baseSettings.Basic.Name + } + $unprotectedVms = Get-ZertoUnprotectedVm + $protectedVms = Get-ZertoProtectedVm + $vmMap = Get-Map -inputObject $unprotectedVms -key VmName -value VmIdentifier + $vmMap = $vmMap + (Get-Map -inputObject $protectedVms -key VmName -value VmIdentifier) + # Create array of VM identifiers + $vmIdentifiers = foreach ($machine in ($Vm | Select-Object -Unique)) { + if ($vmMap[$machine] -notin $baseSettings.Vms.vmIdentifier ) { + # If the VM is unprotected, get the identifier + $vmIdentifier = $unprotectedVms | Where-Object { $_.vmName -like $machine } | Select-Object -ExpandProperty vmIdentifier + # If the VM is not unprotected, check the protected VMs + if ( -not $vmIdentifier) { + # Get all identifiers to test if the VM is eligible to be a member of an additional VPG + $results = $protectedVms | Where-Object { $_.VmName -like $machine } | Select-Object -ExpandProperty vmIdentifier + $recoverySiteIdentifiers = $protectedVms | Where-Object { $_.VmName -like $machine } | Select-Object -ExpandProperty RecoverySite | Select-Object -ExpandProperty identifier + # If VM is currently a member of 3 VPGs, skip it. If it cannot be found, skip it. Otherwise, set the identifier + if ($baseSettings.basic.RecoverySiteIdentifier -in $recoverySiteIdentifiers) { + Write-Warning "$machine is already replicating to target site. It cannot be added to an additional VPG replicating to that site. Please check your configurations and try again. Skipping $machine" + continue + } elseif ($results.count -eq 3) { + Write-Warning "$machine is already a part of 3 VPGs and cannot be part of an additional VPG. Skipping $machine" + continue + } elseif ($results.count -eq 0) { + Write-Warning "$machine not found. Skipping $machine" + continue + } else { + $vmIdentifier = $results | Select-Object -First 1 + } + } + # Create a custom object to store the information to easily convert to JSON. Return to vmIdentifiers array. + $vmIdentifier + } else { + Write-Warning "$machine is already a member of this VPG Settings object. It will not be added again. Skipping $machine" + continue + } + } + if ($vmIdentifiers.Count -gt 0 -and $PSCmdlet.ShouldProcess($VmIdentifiers, "Adding VM(s): $Vm to Vpg $VpgName")) { + foreach ($id in $VmIdentifiers) { + # Build the Body + $Body = @{VmIdentifier = $id } + # Submit the request. Out to Null to prevent line returns while running. + $null = Invoke-ZertoRestRequest -uri $baseUrl -method POST -body ($Body | ConvertTo-Json -Depth 10) + } + + $vpgSettingsIdentifier + } else { + Write-Warning "No VMs found to add. Please check your parameters and try again." + if ($PSCmdlet.ParameterSetName -eq "VpgName") { + Remove-ZertoVpgSettingsIdentifier -vpgSettingsIdentifier $vpgSettingsIdentifier + } + } + } + + end { + + } +} diff --git a/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 index e8d94b7..65dfbfa 100644 --- a/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 @@ -3,13 +3,15 @@ function Checkpoint-ZertoVpg { [cmdletbinding()] param( [Parameter( - Mandatory = $true, - HelpMessage = "Name of the VPG to tag." + Mandatory, + HelpMessage = "Name of the VPG to tag.", + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true )] [ValidateNotNullOrEmpty()] - [string]$vpgName, + [string[]]$vpgName, [Parameter( - Mandatory = $true, + Mandatory, HelpMessage = "Text to tag the checkpoint with." )] [ValidateNotNullOrEmpty()] @@ -18,16 +20,18 @@ function Checkpoint-ZertoVpg { begin { $baseUri = "vpgs" - $vpgIdentifier = $(get-zertovpg -name $vpgName).vpgIdentifier - $body = @{"checkpointName" = $checkpointName} } process { - if ($vpgIdentifier) { - $uri = "{0}/{1}/Checkpoints" -f $baseUri, $vpgIdentifier - Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST" - } else { - Write-Output "Cannot find VPG named $vpgName. Please check the name and try again." + foreach ($name in $vpgName) { + $vpgIdentifier = $(get-zertovpg -name $name).vpgIdentifier + if ($vpgIdentifier) { + $uri = "{0}/{1}/Checkpoints" -f $baseUri, $vpgIdentifier + $body = @{"checkpointName" = $checkpointName } + Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST" + } else { + Write-Output "Cannot find VPG named $name. Please check the name and try again." + } } } diff --git a/ZertoApiWrapper/Public/Connect-ZertoAnalytics.ps1 b/ZertoApiWrapper/Public/Connect-ZertoAnalytics.ps1 new file mode 100644 index 0000000..8bbd20a --- /dev/null +++ b/ZertoApiWrapper/Public/Connect-ZertoAnalytics.ps1 @@ -0,0 +1,20 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Connect-ZertoAnalytics { + [cmdletbinding()] + param( + [Parameter( + Mandatory, + HelpMessage = "PSCredential Object containing username and password authorized for the Zerto Analytics site", + Position = 0 + )] + [System.Management.Automation.PSCredential]$credential + ) + + $uri = "auth/token" + Set-Variable -Name zaHeaders -Scope Script -Value @{"Accept" = "application/json" } + Set-Variable -Name zaLastActionTime -Scope Script -Value $(Get-date).Ticks + $body = @{"username" = $credential.UserName; "password" = $credential.GetNetworkCredential().password } + $result = Invoke-ZARestRequest -Uri $uri -body $($body | ConvertTo-Json) -Method POST + $Script:zaHeaders["Authorization"] = "Bearer $($result.Token)" + $Script:zaHeaders +} diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 5c7b3b0..237f845 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -4,12 +4,19 @@ function Connect-ZertoServer { [OutputType([hashtable])] param( [Parameter( - Mandatory = $true, - HelpMessage = "IP address or FQDN of your Zerto Management Server" + Mandatory, + HelpMessage = "IP address or FQDN of your Zerto Management Server", + Position = 0 )] [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,11 +25,14 @@ function Connect-ZertoServer { [Alias("port")] [string]$zertoPort = "9669", [Parameter( - Mandatory = $true, - HelpMessage = "Valid credentials to connect to the Zerto Management Server" + 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, + [Parameter( + HelpMessage = "Use this switch to return the headers to a specified variable or to the default output." )] - [System.Management.Automation.PSCredential]$credential, [switch]$returnHeaders + ) begin { @@ -32,9 +42,16 @@ function Connect-ZertoServer { Set-Variable -Name zvmServer -Scope Script -Value $zertoServer Set-Variable -Name zvmPort -Scope Script -Value $zertoPort # Set zvmLastAction Variable to keep track when the API token expires - Set-Variable -Name zvmLastAction -Scope Script -Value $(get-date).Ticks + Set-Variable -Name zvmLastAction -Scope Script -Value $(Get-Date).Ticks # Set / Clear the zvmHeaders to clear any existing token - Set-Variable -Name zvmHeaders -Scope Script -Value $null + Set-Variable -Name zvmHeaders -Scope Script -Value @{ + "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 { @@ -44,14 +61,11 @@ function Connect-ZertoServer { end { # Build Headers Hashtable with Authorization Token - $zertoAuthorizationHeaders = @{"x-zerto-session" = $results.Headers['x-zerto-session'][0].ToString(); "Accept" = "application/json"} - # 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) - + $Script:zvmHeaders['x-zerto-session'] = $results.Headers['x-zerto-session'][0].ToString() + # Have the option to return the headers to a variable if ($returnHeaders) { - return $zertoAuthorizationHeaders + return $Script:zvmHeaders } } } diff --git a/ZertoApiWrapper/Public/Copy-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Copy-ZertoVpg.ps1 new file mode 100644 index 0000000..de4f2bc --- /dev/null +++ b/ZertoApiWrapper/Public/Copy-ZertoVpg.ps1 @@ -0,0 +1,59 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Copy-ZertoVpg { + [CmdletBinding(SupportsShouldProcess)] + param ( + # VPG Name to Clone + [Parameter(Mandatory, + HelpMessage = "Name of the VPG to clone")] + [ValidateNotNullOrEmpty()] + [String]$SourceVpgName, + # New VPG Name + [Parameter(Mandatory, + HelpMessage = "Name to assign the newly created VPG")] + [ValidateNotNullOrEmpty()] + [String]$NewVpgName, # Name of VMs to add to the VPG + [Parameter(Mandatory, + HelpMessage = "Name(s) of the Virtual Machine(s) to add to the VPG")] + [ValidateNotNullOrEmpty()] + [String[]]$VMs + ) + + begin { + + } + + process { + $VpgIdToCopy = @{ VpgIdentifier = (Get-ZertoVpg -vpgName $SourceVpgName).vpgIdentifier } + if ( $null -eq $VpgIdToCopy.VpgIdentifier ) { + Throw "Unable to find a VPG with the name: $SourceVpgName. Please check the name and try again." + } + $BaseUri = "vpgSettings/copyVpgSettings" + $VmsMap = Get-Map -InputObject (Get-ZertoUnprotectedVm) -Key 'VmName' -Value 'VmIdentifier' + $VmsMap += Get-Map -InputObject (Get-ZertoProtectedVm) -Key 'VmName' -Value 'VmIdentifier' + $VMsToAdd = foreach ($VM in $VMs) { + if ($VmsMap.Keys -contains $VM) { + [PSCustomObject]@{ + VmIdentifier = $VmsMap[$VM] + } + } else { + Write-Warning -Message "Unable to find VM with Name $VM. Skipping." + } + } + if ($PSCmdlet.ShouldProcess("$VMsToAdd", "Copying $SourceVpgName to $NewVpgName with Settings")) { + $NewVpgId = Invoke-ZertoRestRequest -Uri $BaseUri -Body ($VpgIdToCopy | ConvertTo-Json) -Method "POST" + $Uri = "{0}/{1}/vms" -f "vpgSettings", $NewVpgId + foreach ($VM in $VMsToAdd) { + $null = Invoke-ZertoRestRequest -Uri $Uri -Body ($VM | ConvertTo-Json) -Method "POST" -ErrorAction Stop + } + $Uri = "vpgSettings/{0}" -f $NewVpgId + $CurrentSettings = Invoke-ZertoRestRequest -Uri $Uri + $CurrentSettings.Basic.Name = $NewVpgName + $Null = Invoke-ZertoRestRequest -Uri $Uri -Method "Put" -Body $($CurrentSettings | ConvertTo-Json -Depth 20) + Save-ZertoVpgSetting -vpgSettingsIdentifier $NewVpgId + } + } + + end { + + } +} diff --git a/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 index 4559701..080ec50 100644 --- a/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 @@ -5,12 +5,11 @@ function Disconnect-ZertoServer { $uri = "session" # Delete API Authorization - Invoke-ZertoRestRequest -uri $uri -method DELETE + $null = Invoke-ZertoRestRequest -uri $uri -method DELETE # Remove all variables used Remove-Variable -Name zvmServer -Scope Script Remove-Variable -Name zvmPort -Scope Script Remove-Variable -Name zvmLastAction -Scope Script Remove-Variable -Name zvmHeaders -Scope Script - Remove-Variable -Name zvmLocalInfo -Scope Script } diff --git a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 index acf1693..855f0d4 100644 --- a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 @@ -3,7 +3,7 @@ function Edit-ZertoVra { [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( - Mandatory = $true, + Mandatory, HelpMessage = "Identifier of the VRA to be updated." )] [ValidateNotNullOrEmpty()] @@ -18,20 +18,26 @@ function Edit-ZertoVra { ParameterSetName = "StaticIp", HelpMessage = "Static IP address to assign to the VRA." )] - [ValidateScript( {$_ -match [IPAddress]$_ })] + [ValidateScript( { $_ -match [IPAddress]$_ })] [string]$vraIpAddress, [Parameter( ParameterSetName = "StaticIp", HelpMessage = "Default gateway to assign to the VRA" )] - [ValidateScript( {$_ -match [IPAddress]$_ })] + [ValidateScript( { $_ -match [IPAddress]$_ })] [string]$defaultGateway, [Parameter( ParameterSetName = "StaticIp", HelpMessage = "Subnetmask to be assigned to the VRA" )] - [ValidateScript( {$_ -match [IPAddress]$_ })] - [string]$subnetMask + [ValidateScript( { $_ -match [IPAddress]$_ })] + [string]$subnetMask, + [Parameter( + HelpMessage = "Updated ESXi host root password." + )] + [ValidateNotNullOrEmpty()] + [securestring]$HostRootPassword + ) begin { @@ -39,14 +45,14 @@ function Edit-ZertoVra { # Get the current VRA information for use if an updated parameter is not supplied $vra = Get-ZertoVra -vraIdentifier $vraIdentifier if ( -not $vra ) { - Write-Error "VRA with Identifier: $vraIdentifier could not be found. Please check the ID and try again." + Throw "VRA with Identifier: $vraIdentifier could not be found. Please check the ID and try again." } } process { # Create ordered hashtables to be converted later to JSON. - $vraUpdate = [ordered]@{} - $vraNetwork = [ordered]@{} + $vraUpdate = [ordered]@{ } + $vraNetwork = [ordered]@{ } # If a new group name is specified, update. if ( $PSBoundParameters.ContainsKey('GroupName')) { $vraUpdate['GroupName'] = $groupName @@ -77,8 +83,14 @@ function Edit-ZertoVra { $vraNetwork['VraIPConfigurationTypeApi'] = "Dhcp" $vraUpdate['VraNetworkDataApi'] = $vraNetwork } + if ($PSBoundParameters.ContainsKey('HostRootPassword')) { + $HostRootCredential = [pscredential]::New('root', $HostRootPassword) + $vraUpdate['UsePublicKeyInsteadOfCredentials'] = $false + $vraUpdate['HostRootPassword'] = $HostRootCredential.GetNetworkCredential().Password + } + # -WhatIf processing and submit! - if ($PSCmdlet.ShouldProcess( "Updating " + $vra.vraName + " with these settings: $($vraUpdate | convertTo-Json)")) { + if ($PSCmdlet.ShouldProcess( $vra.vraName )) { Invoke-ZertoRestRequest -uri $baseUri -body $($vraUpdate | ConvertTo-Json) -method "PUT" } } @@ -87,4 +99,4 @@ function Edit-ZertoVra { # Nothing to Do } } -#TODO: Refactor \ No newline at end of file +#TODO: Refactor diff --git a/ZertoApiWrapper/Public/Export-ZertoVmNicSetting.ps1 b/ZertoApiWrapper/Public/Export-ZertoVmNicSetting.ps1 new file mode 100644 index 0000000..110b125 --- /dev/null +++ b/ZertoApiWrapper/Public/Export-ZertoVmNicSetting.ps1 @@ -0,0 +1,83 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Export-ZertoVmNicSetting { + [CmdletBinding()] + param ( + # Vpg(s) to export. If no VPG was named, all data will be exported. + [Parameter( + Helpmessage = "VPG(s) to export" + )] + [ValidateNotNullOrEmpty()] + [string[]] + $VpgName, + # Output file information + [Parameter( + Helpmessage = "File to export the data to. This MUST be a CSV. If a CSV filename is not specified, the file will be forced into a CSV", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string] + $OutputFile + ) + + begin { + } + + process { + if (($OutputFile.Split('.')[-1]) -ne 'csv') { + $OutputFile += '.csv' + } + if ( "VpgName" -in $PSBoundParameters.Keys ) { + $vpgs = Get-ZertoVpg | Where-Object { $_.VpgName -in $VpgName } + foreach ($group in $VpgName) { + if ($group -notin $vpgs.VpgName) { + Write-Error "$group VPG not found. Skipping." -ErrorAction Continue + } + } + } else { + $vpgs = Get-ZertoVpg + } + $nicSettings = foreach ($group in $vpgs) { + $protectedVms = Get-ZertoProtectedVm -vpgName ($group.vpgname) + $vmMap = Get-Map -InputObject $protectedVms -key "vmIdentifier" -value "vmName" + $settingsId = New-ZertoVpgSettingsIdentifier -vpgIdentifier $group.vpgIdentifier + $vmSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $settingsId -vms + $networks = Get-ZertoVirtualizationSite -siteIdentifier $group.RecoverySite.identifier -networks + $null = Remove-ZertoVpgSettingsIdentifier -vpgSettingsIdentifier $settingsId + $networkMap = Get-Map -InputObject $networks -key "NetworkIdentifier" -value "VirtualizationNetworkName" + foreach ($vm in $vmSettings) { + if ($vm.nics.count -gt 0) { + foreach ($nic in $vm.nics) { + $nicInfo = [PSCustomObject]@{ + VPGName = $group.VPGName + VMName = $vmMap[$vm.vmIdentifier] + NicIdentifier = $nic.NicIdentifier + LiveNetwork = $networkMap[$nic.failover.Hypervisor.NetworkIdentifier] + LiveShouldReplaceMac = $nic.failover.Hypervisor.ShouldReplaceMacAddress + LiveIsDHCP = $nic.failover.Hypervisor.IpConfig.IsDhcp + LiveIpAddress = $nic.failover.Hypervisor.IpConfig.StaticIp + LiveIpSubnetMask = $nic.failover.Hypervisor.IpConfig.SubnetMask + LiveIpDefaultGateway = $nic.failover.Hypervisor.IpConfig.Gateway + LivePrimaryDns = $nic.failover.Hypervisor.IpConfig.PrimaryDns + LiveSecondayDns = $nic.failover.Hypervisor.IpConfig.SecondaryDns + LiveDnsSuffix = $nic.failover.Hypervisor.DnsSuffix + TestNetwork = $networkMap[$nic.failoverTest.Hypervisor.NetworkIdentifier] + TestShouldReplaceMac = $nic.failoverTest.Hypervisor.ShouldReplaceMacAddress + TestIsDHCP = $nic.failoverTest.Hypervisor.IpConfig.IsDhcp + TestIpAddress = $nic.failoverTest.Hypervisor.IpConfig.StaticIp + TestIpSubnetMask = $nic.failoverTest.Hypervisor.IpConfig.SubnetMask + TestIpDefaultGateway = $nic.failoverTest.Hypervisor.IpConfig.Gateway + TestPrimaryDns = $nic.failoverTest.Hypervisor.IpConfig.PrimaryDns + TestSecondayDns = $nic.failoverTest.Hypervisor.IpConfig.SecondaryDns + TestDnsSuffix = $nic.failoverTest.Hypervisor.DnsSuffix + } + $nicInfo + } + } + } + } + $nicSettings | Export-Csv -Path $OutputFile -NoTypeInformation + } + + end { + } +} diff --git a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 index 3f5efb8..2d71999 100644 --- a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 @@ -4,7 +4,7 @@ function Export-ZertoVpg { param( [Parameter( HelpMessage = "Location where to dump the resulting JSON files containing the VPG Settings", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [Alias("outputFolder")] @@ -12,7 +12,7 @@ function Export-ZertoVpg { [parameter( HelpMessage = "Name(s) of the VPG(s) to be exported", ParameterSetName = "namedVpgs", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName, @@ -21,7 +21,7 @@ function Export-ZertoVpg { ParameterSetName = "allVpgs", valuefrompipeline = $true, ValueFromPipelineByPropertyName = $true, - Mandatory = $true + Mandatory )] [switch]$allVpgs ) @@ -38,6 +38,7 @@ function Export-ZertoVpg { $vpgSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier $filePath = "{0}\{1}.json" -f $outputPath, $name $vpgSettings | Convertto-Json -depth 10 | Out-File -FilePath $filePath + $null = Remove-ZertoVpgSettingsIdentifier -vpgSettingsIdentifier $vpgSettingsIdentifier } } diff --git a/ZertoApiWrapper/Public/Get-ZAAlert.ps1 b/ZertoApiWrapper/Public/Get-ZAAlert.ps1 new file mode 100644 index 0000000..e173b34 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAAlert.ps1 @@ -0,0 +1,39 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAAlert { + [cmdletbinding( DefaultParameterSetName = "zOrg")] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the alert list. If the ZORG identifier is omitted, a list of all the alerts is retrieved.", + ParameterSetName = "zOrg" + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "The maximum number of alerts to return.", + ParameterSetName = "zOrg" + )] + [ValidateRange(1, 1000000)] + [int]$limitTo, + [Parameter( + HelpMessage = "The alert Idnetifier", + ParameterSetName = "alertId", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$alertIdentifier + ) + $uri = "monitoring/alerts" + switch ($PSCmdlet.ParameterSetName) { + zOrg { + if ( $PSBoundParameters.Keys.Count -gt 0 ) { + $filterString = Get-ZertoApiFilter -filterTable $PSBoundParameters + $uri = "{0}{1}" -f $uri, $filterString + } + } + + alertId { + $uri = "{0}/{1}" -f $uri, $alertIdentifier + } + } + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZADatastore.ps1 b/ZertoApiWrapper/Public/Get-ZADatastore.ps1 new file mode 100644 index 0000000..315e26c --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZADatastore.ps1 @@ -0,0 +1,39 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZADatastore { + [CmdletBinding(DefaultParameterSetName = "AllInfo")] + param ( + [Parameter( + HelpMessage = "The site identifier. The site identifier is mandatory. Omit the datastore and datastore cluster identifiers to view site level storage information.", + Mandatory, + ParameterSetName = "AllInfo" + )] + [Parameter( + Mandatory, + ParameterSetName = "cluster" + )] + [Parameter( + Mandatory, + ParameterSetName = "datastore" + )] + [ValidateNotNullOrEmpty()] + [string]$siteIdentifier, + [Parameter( + HelpMessage = "The datastore cluster identifier. Gets a list of datastores in the cluster.", + ParameterSetName = "cluster", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$clusterIdentifier, + [Parameter( + HelpMessage = "The datastore identifer. Gets the datastore info.", + ParameterSetName = "datastore", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$datastoreIdentifier + + ) + $filter = Get-ZertoApiFilter -filterTable $PSBoundParameters + $uri = "monitoring/datastores{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAEvent.ps1 b/ZertoApiWrapper/Public/Get-ZAEvent.ps1 new file mode 100644 index 0000000..beb9ca9 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAEvent.ps1 @@ -0,0 +1,39 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAEvent { + [cmdletbinding()] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the user's events. If the ZORG identifier is omitted, events is retrieved." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "The event category (events/alertsHistory). Default displays the list of all." + )] + [ValidateSet("events", "alertsHistory")] + [string]$category, + [Parameter( + HelpMessage = "The maximum number of events to return." + )] + [ValidateRange(1, 1000000)] + [int]$limitTo, + [Parameter( + HelpMessage = "The earliest timestamp of an event to return, in RFC 3339 standard ('1970-01-01T00:00:00Z'). Default is one year ago." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The latest timestamp of an event to return, in RFC 3339 standard ('1970-01-01T00:00:00Z'). Default is the present time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + $uri = "monitoring/events" + + if ( $PSBoundParameters.Keys.Count -gt 0 ) { + $filterString = Get-ZertoApiFilter -filterTable $PSBoundParameters + $uri = "{0}{1}" -f $uri, $filterString + } + + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalAverageHistory.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalAverageHistory.ps1 new file mode 100644 index 0000000..4dc0ca2 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalAverageHistory.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalAverageHistory { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per hour, for up to 15 days’ time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/journal-history-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalAverageSize.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalAverageSize.ps1 new file mode 100644 index 0000000..26f7955 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalAverageSize.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalAverageSize { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per hour, for up to 15 days’ time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/journal-size-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalBreach.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalBreach.ps1 new file mode 100644 index 0000000..d4afbf6 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalBreach.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalBreach { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/journal-breach{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalHistoryStat.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalHistoryStat.ps1 new file mode 100644 index 0000000..d973aea --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalHistoryStat.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalHistoryStat { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/stats-journal-history{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalSiteAverageHistory.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalSiteAverageHistory.ps1 new file mode 100644 index 0000000..a9a06f0 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalSiteAverageHistory.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalSiteAverageHistory { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the recovery site. A site identification is required for at least one site.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$recoverySiteIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per hour, for up to 15 days’ time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/site-journal-history-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalSiteAverageSize.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalSiteAverageSize.ps1 new file mode 100644 index 0000000..822f46f --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalSiteAverageSize.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalSiteAverageSize { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the recovery site. A site identification is required for at least one site.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$recoverySiteIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per hour, for up to 15 days’ time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/site-journal-size-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalSiteHistoryStat.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalSiteHistoryStat.ps1 new file mode 100644 index 0000000..c911cd1 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalSiteHistoryStat.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalSiteHistoryStat { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the recovery site.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$recoverySiteIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per hour, for up to 15 days’ time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/site-journal-history-stats{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalSiteHistorySummary.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalSiteHistorySummary.ps1 new file mode 100644 index 0000000..b8f2688 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalSiteHistorySummary.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalSiteHistorySummary { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the recovery site.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$recoverySiteIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per hour, for up to 15 days’ time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/site-journal-history-summary{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalSiteSizeStat.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalSiteSizeStat.ps1 new file mode 100644 index 0000000..0f1df3e --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalSiteSizeStat.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalSiteSizeStat { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$recoverySiteIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per hour, for up to 15 days’ time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/site-journal-size-stats{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalStatusProportion.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalStatusProportion.ps1 new file mode 100644 index 0000000..9595675 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalStatusProportion.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalStatusProportion { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/journal-statuses-proportions{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalStorageStat.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalStorageStat.ps1 new file mode 100644 index 0000000..cf2f520 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalStorageStat.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalStorageStat { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/stats-journal-storage{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAJournalSummary.ps1 b/ZertoApiWrapper/Public/Get-ZAJournalSummary.ps1 new file mode 100644 index 0000000..cdcdb9a --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAJournalSummary.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAJournalSummary { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -filtertable $PSBoundParameters + $uri = "reports/journal-summary{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZALicense.ps1 b/ZertoApiWrapper/Public/Get-ZALicense.ps1 new file mode 100644 index 0000000..bd1bd94 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZALicense.ps1 @@ -0,0 +1,7 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZALicense { + [cmdletbinding()] + param() + $uri = "licenses" + Invoke-ZARestRequest -uri $uri +} \ No newline at end of file diff --git a/ZertoApiWrapper/Public/Get-ZAMonitoring.ps1 b/ZertoApiWrapper/Public/Get-ZAMonitoring.ps1 new file mode 100644 index 0000000..a196baa --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAMonitoring.ps1 @@ -0,0 +1,18 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAMonitoring { + [cmdletbinding()] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the user's statistics for a single account. If the ZORG identifier is omitted, statistics related to all sites, for a single account, is retrieved." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier + ) + $uri = "monitoring/" + if ( -not [String]::IsNullorEmpty($zOrgIdentifier) ){ + $filterTable = @{"zOrgIdentifier" = $zOrgIdentifier} + $filterString = Get-ZertoApiFilter -filterTable $filterTable + $uri = "{0}{1}" -f $uri, $filterString + } + Invoke-ZARestRequest -uri $uri +} \ No newline at end of file diff --git a/ZertoApiWrapper/Public/Get-ZANetworkSiteAverageIOPS.ps1 b/ZertoApiWrapper/Public/Get-ZANetworkSiteAverageIOPS.ps1 new file mode 100644 index 0000000..e329788 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZANetworkSiteAverageIOPS.ps1 @@ -0,0 +1,53 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZANetworkSiteAverageIOPS { + [CmdletBinding(DefaultParameterSetName = "ProtectedSite")] + param ( + [Parameter( + HelpMessage = "Protected site identifier. A site identification is required for at least one of the sites.", + ParameterSetName = "ProtectedSite", + Mandatory + )] + [Parameter( + HelpMessage = "Protected site identifier. A site identification is required for at least one of the sites.", + ParameterSetName = "RecoverySite" + )] + [ValidateNotNullOrEmpty()] + [string]$protectedSiteIdentifier, + [Parameter( + HelpMessage = "Recovery site identifier. If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites.", + ParameterSetName = "RecoverySite", + Mandatory + )] + [Parameter( + HelpMessage = "Recovery site identifier. If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites.", + ParameterSetName = "ProtectedSite" + )] + [ValidateNotNullOrEmpty()] + [string]$recoverySiteIdentifier, + [Parameter( + HelpMessage = "Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the start date is omitted, the default start date is 7 days before the end date." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the end date is omitted, the default end date is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the executive summary." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per hour, for up to 15 days’ time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + + ) + + $filter = Get-ZertoAPIFilter -filtertable $PSBoundParameters + $uri = "reports/sites-network-iops-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZANetworkSiteAveragePerformance.ps1 b/ZertoApiWrapper/Public/Get-ZANetworkSiteAveragePerformance.ps1 new file mode 100644 index 0000000..ad8addc --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZANetworkSiteAveragePerformance.ps1 @@ -0,0 +1,52 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZANetworkSiteAveragePerformance { + [CmdletBinding(DefaultParameterSetName = "ProtectedSite")] + param ( + [Parameter( + HelpMessage = "Protected site identifier. A site identification is required for at least one of the sites.", + ParameterSetName = "ProtectedSite", + Mandatory + )] + [Parameter( + HelpMessage = "Protected site identifier. A site identification is required for at least one of the sites.", + ParameterSetName = "RecoverySite" + )] + [ValidateNotNullOrEmpty()] + [string]$protectedSiteIdentifier, + [Parameter( + HelpMessage = "Recovery site identifier. If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites.", + ParameterSetName = "RecoverySite", + Mandatory + )] + [Parameter( + HelpMessage = "Recovery site identifier. If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites.", + ParameterSetName = "ProtectedSite" + )] + [ValidateNotNullOrEmpty()] + [string]$recoverySiteIdentifier, + [Parameter( + HelpMessage = "Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the start date is omitted, the default start date is 7 days before the end date." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the end date is omitted, the default end date is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the executive summary." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per hour, for up to 15 days’ time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoAPIFilter -filtertable $PSBoundParameters + $uri = "reports/sites-network-performance-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZANetworkSiteStat.ps1 b/ZertoApiWrapper/Public/Get-ZANetworkSiteStat.ps1 new file mode 100644 index 0000000..6762b4a --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZANetworkSiteStat.ps1 @@ -0,0 +1,47 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZANetworkSiteStat { + [CmdletBinding(DefaultParameterSetName = "ProtectedSite")] + param ( + [Parameter( + HelpMessage = "Protected site identifier. A site identification is required for at least one of the sites.", + ParameterSetName = "ProtectedSite", + Mandatory + )] + [Parameter( + HelpMessage = "Protected site identifier. A site identification is required for at least one of the sites.", + ParameterSetName = "RecoverySite" + )] + [ValidateNotNullOrEmpty()] + [string]$protectedSiteIdentifier, + [Parameter( + HelpMessage = "Recovery site identifier. If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites.", + ParameterSetName = "RecoverySite", + Mandatory + )] + [Parameter( + HelpMessage = "Recovery site identifier. If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites.", + ParameterSetName = "ProtectedSite" + )] + [ValidateNotNullOrEmpty()] + [string]$recoverySiteIdentifier, + [Parameter( + HelpMessage = "Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the start date is omitted, the default start date is 7 days before the end date." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the end date is omitted, the default end date is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the executive summary." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier + ) + + $filter = Get-ZertoAPIFilter -filtertable $PSBoundParameters + $uri = "reports/sites-network-stats{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZANetworkSiteSummary.ps1 b/ZertoApiWrapper/Public/Get-ZANetworkSiteSummary.ps1 new file mode 100644 index 0000000..8257ae2 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZANetworkSiteSummary.ps1 @@ -0,0 +1,47 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZANetworkSiteSummary { + [CmdletBinding(DefaultParameterSetName = "ProtectedSite")] + param ( + [Parameter( + HelpMessage = "Protected site identifier. A site identification is required for at least one of the sites.", + ParameterSetName = "ProtectedSite", + Mandatory + )] + [Parameter( + HelpMessage = "Protected site identifier. A site identification is required for at least one of the sites.", + ParameterSetName = "RecoverySite" + )] + [ValidateNotNullOrEmpty()] + [string]$protectedSiteIdentifier, + [Parameter( + HelpMessage = "Recovery site identifier. If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites.", + ParameterSetName = "RecoverySite", + Mandatory + )] + [Parameter( + HelpMessage = "Recovery site identifier. If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites.", + ParameterSetName = "ProtectedSite" + )] + [ValidateNotNullOrEmpty()] + [string]$recoverySiteIdentifier, + [Parameter( + HelpMessage = "Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the start date is omitted, the default start date is 7 days before the end date." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the end date is ommitted, the default end date is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the executive summary." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier + ) + + $filter = Get-ZertoAPIFilter -filtertable $PSBoundParameters + $uri = "reports/sites-network-summary{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZANetworkVpgAverageIOPS.ps1 b/ZertoApiWrapper/Public/Get-ZANetworkVpgAverageIOPS.ps1 new file mode 100644 index 0000000..b8eb8eb --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZANetworkVpgAverageIOPS.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZANetworkVpgAverageIOPS { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The VPG identifier.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the start date is omitted, the default start date is 7 days before the end date." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the end date is omitted, the default end date is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per minute - for up to 6 hours, per hour - for 6 hours to 15 days, or per day - for 15 days up to 30 days. If an interval is not specified, the default is 60 seconds. Submit value in Seconds." + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoAPIFilter -filtertable $PSBoundParameters + $uri = "reports/vpg-network-iops-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZANetworkVpgAveragePerformance.ps1 b/ZertoApiWrapper/Public/Get-ZANetworkVpgAveragePerformance.ps1 new file mode 100644 index 0000000..0485cdb --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZANetworkVpgAveragePerformance.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZANetworkVpgAveragePerformance { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The VPG identifier.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the start date is omitted, the default start date is 7 days before the end date." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the end date is omitted, the default end date is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be per minute - for up to 6 hours, per hour - for 6 hours to 15 days, or per day - for 15 days up to 30 days. If an interval is not specified, the default is 60 seconds. Submit value in Seconds." + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoAPIFilter -filtertable $PSBoundParameters + $uri = "reports/vpg-network-performance-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZANetworkVpgStat.ps1 b/ZertoApiWrapper/Public/Get-ZANetworkVpgStat.ps1 new file mode 100644 index 0000000..c135c6f --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZANetworkVpgStat.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZANetworkVpgStat { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The VPG identifier.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the start date is omitted, the default start date is 7 days before the end date." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the end date is omitted, the default end date is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoAPIFilter -filtertable $PSBoundParameters + $uri = "reports/vpg-network-stats{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZANetworkVpgSummary.ps1 b/ZertoApiWrapper/Public/Get-ZANetworkVpgSummary.ps1 new file mode 100644 index 0000000..3654fcd --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZANetworkVpgSummary.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZANetworkVpgSummary { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The VPG identifier.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the start date is omitted, the default start date is 7 days before the end date." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the end date is omitted, the default end date is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoAPIFilter -filtertable $PSBoundParameters + $uri = "reports/vpg-network-summary{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAPlannerJournalSizeReport.ps1 b/ZertoApiWrapper/Public/Get-ZAPlannerJournalSizeReport.ps1 new file mode 100644 index 0000000..5ea91a5 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAPlannerJournalSizeReport.ps1 @@ -0,0 +1,58 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAPlannerJournalSizeReport { + [cmdletbinding()] + param( + [Parameter( + Mandatory, + HelpMessage = "The site identifier(s) for which to return detailed information." + )] + [ValidateNotNullOrEmpty()] + [string]$siteIdentifier, + [Parameter( + Mandatory, + HelpMessage = "Type of target recovery site." + )] + [ValidateSet('azure', 'vcenter', 'vcd', 'scvmm', 'aws')] + [string]$recoveryType, + [Parameter( + Mandatory, + HelpMessage = "Identifiers of the VMs you want to recover at the target recovery site." + )] + [ValidateNotNullOrEmpty()] + [string[]]$vmIdentifier, + [Parameter( + HelpMessage = "The desired journal history in hours. The default is 24 hours. Limited to a 1 hour up to 720 hours, or the equivalent of 30 days" + )] + [ValidateRange(1, 720)] + [Int]$desiredJournalHistory = 24, + [Parameter( + HelpMessage = "The earliest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is one year ago." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The latest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + $uri = "planner/reports/stats/journal-size" + $body = @{ + siteIdentifier = $siteIdentifier + recoveryType = $recoveryType + desiredJournalHistory = $desiredJournalHistory + vms = New-Object System.Collections.Generic.List[psobject] + } + if ( -not [String]::IsNullOrEmpty($startDate) ) { + $body['startDate'] = $startDate + } + if ( -not [String]::IsNullOrEmpty($endDate) ) { + $body['endDate'] = $endDate + } + foreach ($vmId in $vmIdentifier) { + $body['vms'].Add(@{'identifier' = $vmId; 'desiredJournalHistory' = $desiredJournalHistory }) + } + $reportId = Invoke-ZARestRequest -uri $uri -method POST -body ($body | ConvertTo-Json) + $uri = '{0}?reportId={1}' -f $uri, $reportId.reportId + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAPlannerNetworkPerformanceReport.ps1 b/ZertoApiWrapper/Public/Get-ZAPlannerNetworkPerformanceReport.ps1 new file mode 100644 index 0000000..c0a6b12 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAPlannerNetworkPerformanceReport.ps1 @@ -0,0 +1,58 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAPlannerNetworkPerformanceReport { + [cmdletbinding()] + param( + [Parameter( + Mandatory, + HelpMessage = "The site identifier(s) for which to return detailed information." + )] + [ValidateNotNullOrEmpty()] + [string]$siteIdentifier, + [Parameter( + Mandatory, + HelpMessage = "Type of target recovery site." + )] + [ValidateSet('azure', 'vcenter', 'vcd', 'scvmm', 'aws')] + [string]$recoveryType, + [Parameter( + Mandatory, + HelpMessage = "Identifiers of the VMs you want to recover at the target recovery site." + )] + [ValidateNotNullOrEmpty()] + [string[]]$vmIdentifier, + [Parameter( + HelpMessage = "The desired sample interval in seconds. The default is 3600 seconds (1 Hour). Limited to a 60 second to 86,400 second (24 Hour) interval" + )] + [ValidateRange(60, 86400)] + [Int]$interval = 3600, + [Parameter( + HelpMessage = "The earliest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is one year ago." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The latest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + $uri = "planner/reports/network-performance" + $body = @{ + siteIdentifier = $siteIdentifier + recoveryType = $recoveryType + interval = $interval + vmIdentifiers = New-Object System.Collections.Generic.List[psobject] + } + if ( -not [String]::IsNullOrEmpty($startDate) ) { + $body['startDate'] = $startDate + } + if ( -not [String]::IsNullOrEmpty($endDate) ) { + $body['endDate'] = $endDate + } + foreach ($vmId in $vmIdentifier) { + $body['vmIdentifiers'].Add($vmId) + } + $reportId = Invoke-ZARestRequest -uri $uri -method POST -body ($body | ConvertTo-Json) + $uri = '{0}?reportId={1}' -f $uri, $reportId.reportId + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAPlannerSite.ps1 b/ZertoApiWrapper/Public/Get-ZAPlannerSite.ps1 new file mode 100644 index 0000000..44adc6c --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAPlannerSite.ps1 @@ -0,0 +1,22 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAPlannerSite { + [cmdletbinding()] + param( + [Parameter( + HelpMessage = "The site identifier(s) for which to return detailed information." + )] + [ValidateNotNullOrEmpty()] + [string[]]$siteIdentifier + ) + $uri = "planner/sites" + if ( -not [String]::IsNullorEmpty($siteIdentifier) ) { + $entry = foreach ($id in $siteIdentifier) { + "{0}/{1}" -f $uri, $id + } + } else { + $entry = $uri + } + foreach ($uri in $entry) { + Invoke-ZARestRequest -uri $uri + } +} diff --git a/ZertoApiWrapper/Public/Get-ZAPlannerStatsReport.ps1 b/ZertoApiWrapper/Public/Get-ZAPlannerStatsReport.ps1 new file mode 100644 index 0000000..e247c86 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAPlannerStatsReport.ps1 @@ -0,0 +1,58 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAPlannerStatsReport { + [cmdletbinding()] + param( + [Parameter( + Mandatory, + HelpMessage = "The site identifier(s) for which to return detailed information." + )] + [ValidateNotNullOrEmpty()] + [string]$siteIdentifier, + [Parameter( + Mandatory, + HelpMessage = "Type of target recovery site." + )] + [ValidateSet('azure', 'vcenter', 'vcd', 'scvmm', 'aws')] + [string]$recoveryType, + [Parameter( + Mandatory, + HelpMessage = "Identifiers of the VMs you want to recover at the target recovery site." + )] + [ValidateNotNullOrEmpty()] + [string[]]$vmIdentifier, + [Parameter( + HelpMessage = "The desired journal history in hours. The default is 24 hours. Limited to a 1 hour up to 720 hours, or the equivalent of 30 days" + )] + [ValidateRange(1, 720)] + [Int]$desiredJournalHistory = 24, + [Parameter( + HelpMessage = "The earliest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is one year ago." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The latest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + $uri = "planner/reports/stats" + $body = @{ + siteIdentifier = $siteIdentifier + recoveryType = $recoveryType + desiredJournalHistory = $desiredJournalHistory + vms = New-Object System.Collections.Generic.List[psobject] + } + if ( -not [String]::IsNullOrEmpty($startDate) ) { + $body['startDate'] = $startDate + } + if ( -not [String]::IsNullOrEmpty($endDate) ) { + $body['endDate'] = $endDate + } + foreach ($vmId in $vmIdentifier) { + $body['vms'].Add(@{'identifier' = $vmId; 'desiredJournalHistory' = $desiredJournalHistory }) + } + $reportId = Invoke-ZARestRequest -uri $uri -method POST -body ($body | ConvertTo-Json) + $uri = '{0}?reportId={1}' -f $uri, $reportId.reportId + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAPlannerWanReport.ps1 b/ZertoApiWrapper/Public/Get-ZAPlannerWanReport.ps1 new file mode 100644 index 0000000..f678504 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAPlannerWanReport.ps1 @@ -0,0 +1,52 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAPlannerWanReport { + [cmdletbinding()] + param( + [Parameter( + Mandatory, + HelpMessage = "The site identifier(s) for which to return detailed information." + )] + [ValidateNotNullOrEmpty()] + [string]$siteIdentifier, + [Parameter( + Mandatory, + HelpMessage = "Type of target recovery site." + )] + [ValidateSet('azure', 'vcenter', 'vcd', 'scvmm', 'aws')] + [string]$recoveryType, + [Parameter( + Mandatory, + HelpMessage = "Identifiers of the VMs you want to recover at the target recovery site." + )] + [ValidateNotNullOrEmpty()] + [string[]]$vmIdentifier, + [Parameter( + HelpMessage = "The earliest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is one year ago." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The latest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + $uri = "planner/reports/stats/wan" + $body = @{ + siteIdentifier = $siteIdentifier + recoveryType = $recoveryType + vmIdentifiers = New-Object System.Collections.Generic.List[psobject] + } + if ( -not [String]::IsNullOrEmpty($startDate) ) { + $body['startDate'] = $startDate + } + if ( -not [String]::IsNullOrEmpty($endDate) ) { + $body['endDate'] = $endDate + } + foreach ($vmId in $vmIdentifier) { + $body['vmIdentifiers'].Add($vmId) + } + $reportId = Invoke-ZARestRequest -uri $uri -method POST -body ($body | ConvertTo-Json) + $uri = '{0}?reportId={1}' -f $uri, $reportId.reportId + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAPlannerZcasReport.ps1 b/ZertoApiWrapper/Public/Get-ZAPlannerZcasReport.ps1 new file mode 100644 index 0000000..c278502 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAPlannerZcasReport.ps1 @@ -0,0 +1,54 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAPlannerZcasReport { + [cmdletbinding()] + param( + [Parameter( + Mandatory, + HelpMessage = "The site identifier(s) for which to return detailed information." + )] + [ValidateNotNullOrEmpty()] + [string]$siteIdentifier, + [Parameter( + Mandatory, + HelpMessage = "Type of target recovery site." + )] + [ValidateSet('azure', 'vcenter', 'vcd', 'scvmm', 'aws')] + [string]$recoveryType, + [Parameter( + Mandatory, + HelpMessage = "Identifiers of the VMs you want to recover at the target recovery site." + )] + [ValidateNotNullOrEmpty()] + [string[]]$vmIdentifier, + [Parameter( + HelpMessage = "The earliest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is one year ago." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The latest timestamp of an event to return, in RFC 3339 standard. ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + $uri = "planner/reports/stats/zcas" + $body = @{ + siteIdentifier = $siteIdentifier + recoveryType = $recoveryType + vmIdentifiers = New-Object System.Collections.Generic.List[psobject] + } + if ( -not [String]::IsNullOrEmpty($startDate) ) { + $body['startDate'] = $startDate + } + if ( -not [String]::IsNullOrEmpty($endDate) ) { + $body['endDate'] = $endDate + } + foreach ($vmId in $vmIdentifier) { + $body['vmIdentifiers'].Add($vmId) + } + #$body | ConvertTo-Json + $reportId = Invoke-ZARestRequest -uri $uri -method POST -body ($body | ConvertTo-Json) + #Start-Sleep 10 + $uri = '{0}?reportId={1}' -f $uri, $reportId.reportId + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAProtectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZAProtectedVm.ps1 new file mode 100644 index 0000000..86299ba --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAProtectedVm.ps1 @@ -0,0 +1,51 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAProtectedVm { + [cmdletbinding(DefaultParameterSetName = "AllVMs")] + param( + [Parameter( + ParameterSetName = "AllVMs", + HelpMessage = "Use this switch when you want a list of all protected VMs. Please be warned this list can be quite large." + )] + [switch]$AllVms, + [Parameter( + ParameterSetName = "IndividualVMs", + Mandatory, + HelpMessage = "A list of VM identifiers to query" + )] + [ValidateNotNullOrEmpty()] + [string[]]$VMIdentifier, + [Parameter( + ParameterSetName = "IndividualVMs", + HelpMessage = "Specify this switch when you would like protected vms' volume information returned" + )] + [switch]$Volumes + ) + + Begin { + + } + + Process { + $BaseUri = "monitoring/protected-vms" + switch ($PSCmdlet.ParameterSetName) { + "AllVMs" { + Invoke-ZARestRequest -uri $BaseUri + } + + "IndividualVMs" { + foreach ($identifier in $VMIdentifier) { + if ($Volumes.IsPresent) { + $Uri = "{0}/{1}/volumes" -f $BaseUri, $identifier + } else { + $uri = $Uri = "{0}/{1}" -f $BaseUri, $identifier + } + Invoke-ZARestRequest -uri $Uri + } + } + } + } + + End { + + } +} diff --git a/ZertoApiWrapper/Public/Get-ZAProtectedVmReport.ps1 b/ZertoApiWrapper/Public/Get-ZAProtectedVmReport.ps1 new file mode 100644 index 0000000..c02b0cd --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAProtectedVmReport.ps1 @@ -0,0 +1,32 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAProtectedVmReport { + [cmdletbinding()] + param( + [Parameter( + ParameterSetName = "GenerateReport", + Mandatory, + HelpMessage = "A list of VM identifiers to include in the report." + )] + [ValidateNotNullOrEmpty()] + [string[]]$VMIdentifier + ) + + Begin { + + } + + Process { + $BaseUri = "monitoring/protected-vms" + $Body = @{ + vmsIdentifiers = $VMIdentifier + } + $reportId = Invoke-ZARestRequest -uri $BaseUri -method POST -body ($Body | ConvertTo-Json) + Start-Sleep 1 + $Uri = "{0}?reportId={1}" -f $BaseUri, $reportId.reportId + Invoke-ZARestRequest -uri $Uri + } + + End { + + } +} diff --git a/ZertoApiWrapper/Public/Get-ZARPOAccountAverage.ps1 b/ZertoApiWrapper/Public/Get-ZARPOAccountAverage.ps1 new file mode 100644 index 0000000..d9149fc --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZARPOAccountAverage.ps1 @@ -0,0 +1,25 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZARPOAccountAverage { + [CmdletBinding()] + param ( + [Parameter( + Helpmessage = "The ZORG identifier by which to filter the user's average RPO for a single account. If the ZORG identifier is omitted, statistics related to all sites, for a single account, is retrieved." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -FilterTable $PSBoundParameters + $uri = "reports/account-rpo-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZARPOAverage.ps1 b/ZertoApiWrapper/Public/Get-ZARPOAverage.ps1 new file mode 100644 index 0000000..2114c85 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZARPOAverage.ps1 @@ -0,0 +1,31 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZARPOAverage { + [CmdletBinding()] + param ( + [Parameter( + Helpmessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate, + [Parameter( + HelpMessage = "The interval selected within the duration of the report. The interval can be 1-minute data granularity for up to 6 hours’ time frame, 1-hour data granularity for 6 hours to 15 days’ time frame or 1-day data granularity for 15 days up to 30 days’ time frame. Value should be submitted in Seconds" + )] + [ValidateRange(60, 2678400)] + [Int32]$interval + ) + + $filter = Get-ZertoApiFilter -FilterTable $PSBoundParameters + $uri = "reports/rpo-average{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZARPOBreach.ps1 b/ZertoApiWrapper/Public/Get-ZARPOBreach.ps1 new file mode 100644 index 0000000..3030cca --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZARPOBreach.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZARPOBreach { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -FilterTable $PSBoundParameters + $uri = "reports/rpo-breach{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZARPOStat.ps1 b/ZertoApiWrapper/Public/Get-ZARPOStat.ps1 new file mode 100644 index 0000000..14f9a29 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZARPOStat.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZARPOStat { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -FilterTable $PSBoundParameters + $uri = "reports/stats-rpo{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZARPOStatusProportion.ps1 b/ZertoApiWrapper/Public/Get-ZARPOStatusProportion.ps1 new file mode 100644 index 0000000..493d7f7 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZARPOStatusProportion.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZARPOStatusProportion { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -FilterTable $PSBoundParameters + $uri = "reports/rpo-statuses-proportions{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZARPOSummary.ps1 b/ZertoApiWrapper/Public/Get-ZARPOSummary.ps1 new file mode 100644 index 0000000..58f3a61 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZARPOSummary.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZARPOSummary { + [CmdletBinding()] + param ( + [Parameter( + HelpMessage = "The identifier of the VPG.", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier, + [Parameter( + HelpMessage = "The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). If only the end date is added, the start date by default will be the end date minus 7 days." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). The default is the current time." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + + $filter = Get-ZertoApiFilter -FilterTable $PSBoundParameters + $uri = "reports/rpo-summary{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZASite.ps1 b/ZertoApiWrapper/Public/Get-ZASite.ps1 new file mode 100644 index 0000000..dc2b66d --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZASite.ps1 @@ -0,0 +1,18 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZASite { + [cmdletbinding()] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter site list. If the ZORG identifier is omitted, a list of all sites is retrieved." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier + ) + $uri = "monitoring/sites" + if ( -not [String]::IsNullorEmpty($zOrgIdentifier) ) { + $filterTable = @{"zOrgIdentifier" = $zOrgIdentifier } + $filterString = Get-ZertoApiFilter -filterTable $filterTable + $uri = "{0}{1}" -f $uri, $filterString + } + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZASitePair.ps1 b/ZertoApiWrapper/Public/Get-ZASitePair.ps1 new file mode 100644 index 0000000..1c3d724 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZASitePair.ps1 @@ -0,0 +1,24 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZASitePair { + [cmdletbinding()] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the site list. If the ZORG identifier is omitted, a list of all sites is retrieved." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the start date is omitted, the default start date is 7 days before the end date." + )] + [ValidateNotNullOrEmpty()] + [string]$startDate, + [Parameter( + HelpMessage = "End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). If the end date is omitted, the default endDate is the current date." + )] + [ValidateNotNullOrEmpty()] + [string]$endDate + ) + $filter = Get-ZertoApiFilter -filterTable $PSBoundParameters + $uri = "reports/sites-list{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZASiteTopology.ps1 b/ZertoApiWrapper/Public/Get-ZASiteTopology.ps1 new file mode 100644 index 0000000..82795c3 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZASiteTopology.ps1 @@ -0,0 +1,20 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZASiteTopology { + [cmdletbinding()] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter sites topology list. If the ZORG identifier is omitted, information related to all sites topology is retrieved." + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier + ) + $uri = "monitoring/sites" + if ( -not [String]::IsNullorEmpty($zOrgIdentifier) ) { + $filterTable = @{"zOrgIdentifier" = $zOrgIdentifier } + $filterString = Get-ZertoApiFilter -filterTable $filterTable + $uri = "{0}{1}&format=topology" -f $uri, $filterString + } else { + $uri = "{0}?format=topology" -f $uri + } + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZATask.ps1 b/ZertoApiWrapper/Public/Get-ZATask.ps1 new file mode 100644 index 0000000..d13ebb3 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZATask.ps1 @@ -0,0 +1,39 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZATask { + [cmdletbinding( DefaultParameterSetName = "zOrg")] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the task list. If the ZORG identifier is omitted, a list of all the tasks is retrieved.", + ParameterSetName = "zOrg" + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "The maximum number of tasks to return.", + ParameterSetName = "zOrg" + )] + [ValidateRange(1, 1000000)] + [int]$limitTo, + [Parameter( + HelpMessage = "The task Idnetifier", + ParameterSetName = "taskId", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$taskIdentifier + ) + $uri = "monitoring/tasks" + switch ($PSCmdlet.ParameterSetName) { + zOrg { + if ( $PSBoundParameters.Keys.Count -gt 0 ) { + $filterString = Get-ZertoApiFilter -filterTable $PSBoundParameters + $uri = "{0}{1}" -f $uri, $filterString + } + } + + taskId { + $uri = "{0}/{1}" -f $uri, $taskIdentifier + } + } + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAVolume.ps1 b/ZertoApiWrapper/Public/Get-ZAVolume.ps1 new file mode 100644 index 0000000..662448e --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAVolume.ps1 @@ -0,0 +1,44 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAVolume { + [CmdletBinding(DefaultParameterSetName = "VpgIdentifier")] + param ( + [Parameter( + HelpMessage = "The site identifier. The site identifier is mandatory if vpgIdentifier is not entered.", + Mandatory, + ParameterSetName = "SiteAndClusterIdentifier" + )] + [Parameter( + HelpMessage = "The site identifier. The site identifier is mandatory if vpgIdentifier is not entered.", + Mandatory, + ParameterSetName = "SiteAndDatastoreIdentifier" + )] + [ValidateNotNullOrEmpty()] + [string]$siteIdentifier, + [Parameter( + HelpMessage = "The cluster identifier. If a cluster identifier is not entered, you must enter a datastore identifier.", + Mandatory, + ParameterSetName = "SiteAndClusterIdentifier" + )] + [ValidateNotNullOrEmpty()] + [string]$clusterIdentifier, + [Parameter( + HelpMessage = "The datastore identifer. If a datastore identifier is not entered, you must enter a cluster identifier.", + Mandatory, + ParameterSetName = "SiteAndDatastoreIdentifier" + )] + [ValidateNotNullOrEmpty()] + [string]$datastoreIdentifier, + [Parameter( + HelpMessage = "The vpg identifer.", + Mandatory, + ParameterSetName = "VpgIdentifier" + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier + + ) + + $filter = Get-ZertoApiFilter -FilterTable $PSBoundParameters + $uri = "monitoring/volumes{0}" -f $filter + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAVpg.ps1 b/ZertoApiWrapper/Public/Get-ZAVpg.ps1 new file mode 100644 index 0000000..bb50cb8 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAVpg.ps1 @@ -0,0 +1,36 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAVpg { + [cmdletbinding(DefaultParameterSetName = 'zOrg')] + param( + [Parameter( + HelpMessage = "The ZORG identifier by which to filter the VPG list. If the ZORG identifier is omitted, a list of all VPGs is retrieved.", + ParameterSetName = 'zOrg' + )] + [ValidateNotNullOrEmpty()] + [string]$zOrgIdentifier, + [Parameter( + HelpMessage = "The VPG Identifier", + ParameterSetName = "vpg", + Mandatory + )] + [ValidateNotNullOrEmpty()] + [string]$vpgIdentifier + ) + $uri = "monitoring/vpgs" + + switch ($PSCmdlet.ParameterSetName) { + zOrg { + if ( -not [String]::IsNullorEmpty($zOrgIdentifier) ) { + $filterTable = @{"zOrgIdentifier" = $zOrgIdentifier } + $filterString = Get-ZertoApiFilter -filterTable $filterTable + $uri = "{0}{1}" -f $uri, $filterString + } + } + + vpg { + $uri = "{0}/$vpgIdentifier" -f $uri + } + } + + Invoke-ZARestRequest -uri $uri +} diff --git a/ZertoApiWrapper/Public/Get-ZAzOrg.ps1 b/ZertoApiWrapper/Public/Get-ZAzOrg.ps1 new file mode 100644 index 0000000..7a69bc1 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAzOrg.ps1 @@ -0,0 +1,7 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAzOrg { + [cmdletbinding()] + param() + $uri = "monitoring/zorgs" + Invoke-ZARestRequest -uri $uri +} \ No newline at end of file diff --git a/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 b/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 index 1ee27f6..d9d9181 100644 --- a/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 @@ -4,7 +4,7 @@ function Get-ZertoAlert { param( [Parameter( ParameterSetName = "alertId", - Mandatory = $true, + Mandatory, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true , HelpMessage = "AlertId or array of AlertIds to be queried" @@ -13,19 +13,19 @@ function Get-ZertoAlert { [string[]]$alertId, [Parameter( ParameterSetName = "entities", - Mandatory = $true, + Mandatory, HelpMessage = "Switch to return the entities information from the API" )] [switch]$entities, [Parameter( ParameterSetName = "helpIdentifiers", - Mandatory = $true, + Mandatory, HelpMessage = "Switch to get the Help Identifiers information from the API" )] [switch]$helpIdentifiers, [Parameter( ParameterSetName = "levels", - Mandatory = $true, + Mandatory, HelpMessage = "Switch to return Alert Levels information from the API" )] [switch]$levels, @@ -43,7 +43,7 @@ function Get-ZertoAlert { [string]$endDate, [Parameter( ParameterSetName = "filter", - HelpMessage = "Returns alerts for the specified vraIdentifier" + HelpMessage = "Returns alerts for the specified vpgIdentifier" )] [ValidateNotNullOrEmpty()] [Alias("vpgId")] diff --git a/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 b/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 index 1c45ee8..3f49004 100644 --- a/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 @@ -69,7 +69,7 @@ function Get-ZertoEvent { ParameterSetName = "filter", HelpMessage = "The type of event to return. This filter behaves in the same way as the eventCategory filter. Possible Values are: Possible Values are: 'All', 'Events', 'Alerts'" )] - [ValidateNotNullOrEmpty()] + [ValidateSet('All', 'Events', 'Alerts')] [string]$category, [Parameter( ParameterSetName = "filter", @@ -86,7 +86,7 @@ function Get-ZertoEvent { [string]$alertIdentifier, [Parameter( ParameterSetName = "eventId", - Mandatory = $true, + Mandatory, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The identifier or identifiers of the event for which information is returned." @@ -95,19 +95,19 @@ function Get-ZertoEvent { [string[]]$eventId, [Parameter( ParameterSetName = "categories", - Mandatory = $true, + Mandatory, HelpMessage = "Returns possible Event Categories." )] [switch]$categories, [Parameter( ParameterSetName = "entities", - Mandatory = $true, + Mandatory, HelpMessage = "Returns possible entity types." )] [switch]$entities, [Parameter( ParameterSetName = "types", - Mandatory = $true, + Mandatory, HelpMessage = "Returns possible event types.")] [switch]$types ) @@ -137,6 +137,10 @@ function Get-ZertoEvent { # If a filter is applied, create the filter and return the events that fall in that filter "filter" { $filter = Get-ZertoApiFilter -filterTable $PSBoundParameters + if ($PSBoundParameters.Keys -contains 'vpg') { + $vpgIdentifier = (Get-ZertoVpg -name $vpg).vpgIdentifier + $filter = $filter.replace("vpg=$vpg", "vpg=$vpgIdentifier") + } $uri = "{0}{1}" -f $baseUri, $filter $returnObject = Invoke-ZertoRestRequest -uri $uri } diff --git a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 index 8f64673..d5c42e3 100644 --- a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 @@ -5,12 +5,12 @@ function Get-ZertoPeerSite { [Parameter( ParameterSetName = "pairingStatuses", HelpMessage = "Switch to return possible paiting statuses.", - Mandatory = $true + Mandatory )] [switch]$pairingStatuses, [Parameter( ParameterSetName = "siteIdentifier", - Mandatory = $true, + Mandatory, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The identifier(s) of the peer site(s) for which information is to be returned." @@ -22,6 +22,7 @@ function Get-ZertoPeerSite { ParameterSetName = "filter", HelpMessage = "The name of a peer site for which information is to be returned. The name is case-sensitive." )] + [ValidateNotNullOrEmpty()] [string]$peerName, [Parameter ( ParameterSetName = "filter", diff --git a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 index 36dc2aa..e559926 100644 --- a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 @@ -4,7 +4,7 @@ function Get-ZertoProtectedVm { param ( [Parameter( ParameterSetName = "vmIdentifier", - Mandatory = $true, + Mandatory, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "vmIdentifier(s) for which to return information" diff --git a/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 b/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 index c15ba9c..fded034 100644 --- a/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 @@ -26,12 +26,6 @@ function Get-ZertoRecoveryReport { )] [ValidateNotNullOrEmpty()] [string]$pageSize, - [Parameter( - ParameterSetName = "filter", - HelpMessage = "The internal identifier of the VPG. You can specify more than one VPG, separated by commas." - )] - [ValidateNotNullOrEmpty()] - [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the VPG. You can specify more than one VPG, separated by commas." 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/Get-ZertoVirtualizationSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 index e296887..ddaaf20 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 @@ -4,52 +4,57 @@ function Get-ZertoVirtualizationSite { param( [Parameter( ParameterSetName = "siteIdentifier", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [Parameter( ParameterSetName = "datastoreClusters", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [Parameter( ParameterSetName = "datastores", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [Parameter( ParameterSetName = "hostClusters", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [Parameter( ParameterSetName = "hosts", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [Parameter( ParameterSetName = "networks", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [Parameter( ParameterSetName = "resourcePools", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [Parameter( ParameterSetName = "vms", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [Parameter( ParameterSetName = "devices", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [Parameter( ParameterSetName = "folders", - Mandatory = $true, + Mandatory, + HelpMessage = "The identifier of the Zerto Virtual Manager site." + )] + [Parameter( + ParameterSetName = "repositories", + Mandatory, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] [ValidateNotNullOrEmpty()] @@ -57,19 +62,19 @@ function Get-ZertoVirtualizationSite { [string]$siteIdentifier, [Parameter( ParameterSetName = "datastoreClusters", - Mandatory = $true, + Mandatory, HelpMessage = "When selected, will return all datastore clusters at the specified site." )] [switch]$datastoreClusters, [Parameter( ParameterSetName = "datastores", - Mandatory = $true, + Mandatory, HelpMessage = "When selected, will return all datastores at the specified site." )] [switch]$datastores, [Parameter( ParameterSetName = "devices", - Mandatory = $true, + Mandatory, HelpMessage = "When selected, will return all devices at the specified site." )] [switch]$devices, @@ -88,66 +93,67 @@ function Get-ZertoVirtualizationSite { [string]$hostIdentifier, [Parameter( ParameterSetName = "folders", - Mandatory = $true, + Mandatory, HelpMessage = "Return all folders at the selected site." )] [switch]$folders, [Parameter( ParameterSetName = "hostClusters", - Mandatory = $true, + Mandatory, HelpMessage = "Return all host clusters at the selected site." )] [switch]$hostClusters, [Parameter( ParameterSetName = "hosts", - Mandatory = $true, + Mandatory, HelpMessage = "Return all hosts at the selected site. If a host identifier is provided, return only that host." )] [switch]$hosts, [Parameter( ParameterSetName = "networks", - Mandatory = $true, + Mandatory, HelpMessage = "Return all networks at the selected site." )] [switch]$networks, [Parameter( ParameterSetName = "resourcePools", - Mandatory = $true, + Mandatory, HelpMessage = "Return all resource pools at the selected site." )] [switch]$resourcePools, [Parameter( ParameterSetName = "vms", - Mandatory = $true, + Mandatory, HelpMessage = "Return all VMs at the selected site." )] - [switch]$vms + [switch]$vms, + [Parameter( + ParameterSetName = "repositories", + Mandatory, + HelpMessage = "The identifier of the Zerto Virtual Manager site." + )] + [switch]$repositories ) begin { - $baseUri = "virtualizationsites" - $returnObject = @() + } process { # Return information based on ParameterSetName invoked. + $baseUri = "virtualizationsites" switch ( $PSCmdlet.ParameterSetName ) { - # If no ParameterSetName is specified, return all data "main" { - $returnObject = Invoke-ZertoRestRequest -uri $baseUri + $uri = $baseUri } # If devices is specified along with a hostId, build return just that host information, otherwise return all devices at the site - #TODO - remove foreach, only one siteIdentifier can be specified. "devices" { - $returnObject = foreach ( $id in $siteIdentifier ) { - if ( $PSBoundParameters.ContainsKey( "hostIdentifier" ) ) { - $uri = "{0}/{1}/devices?hostIdentifier={2}" -f $baseUri, $siteIdentifier, $hostIdentifier - } else { - $uri = "{0}/{1}/devices" -f $baseUri, $siteIdentifier - } - Invoke-ZertoRestRequest -uri $uri + if ( $PSBoundParameters.ContainsKey( "hostIdentifier" ) ) { + $uri = "{0}/{1}/devices?hostIdentifier={2}" -f $baseUri, $siteIdentifier, $hostIdentifier + } else { + $uri = "{0}/{1}/devices" -f $baseUri, $siteIdentifier } } @@ -158,24 +164,22 @@ function Get-ZertoVirtualizationSite { } else { $uri = "{0}/{1}/hosts" -f $baseUri, $siteIdentifier } - $returnObject = Invoke-ZertoRestRequest -uri $uri } # If siteIdentifier is specified, return information for that site. "siteIdentifier" { $uri = "{0}/{1}" -f $baseUri, $siteIdentifier - $returnObject = Invoke-ZertoRestRequest -uri $uri } # If a different ParameterSetName is selected, use that information to build the URI and return that information default { $uri = "{0}/{1}/{2}" -f $baseUri, $siteIdentifier, $PSCmdlet.ParameterSetName.ToLower() - $returnObject = Invoke-ZertoRestRequest -uri $uri } } + Invoke-ZertoRestRequest -uri $uri } end { - return $returnObject + } } diff --git a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 index d151152..c26a968 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 @@ -4,17 +4,17 @@ function Get-ZertoVpg { param( [Parameter( ParameterSetName = "protectionGroupIdentifier", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier(s) of the Virtual Protection Group to return" )] [Parameter( ParameterSetName = "checkpoints", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier(s) of the Virtual Protection Group to return" )] [Parameter( ParameterSetName = "stats", - Mandatory = $true, + Mandatory, HelpMessage = "The identifier(s) of the Virtual Protection Group to return" )] [ValidateNotNullOrEmpty()] @@ -22,7 +22,7 @@ function Get-ZertoVpg { [string[]]$protectionGroupIdentifier, [Parameter( ParameterSetName = "checkpoints", - Mandatory = $true, + Mandatory, HelpMessage = "Return checkpoints for the selected Virtual Protection Group." )] [switch]$checkpoints, @@ -39,49 +39,49 @@ function Get-ZertoVpg { [ValidateNotNullOrEmpty()] [string]$endDate, [Parameter( - ParameterSetName = "stats", Mandatory = $true, + ParameterSetName = "stats", Mandatory, HelpMessage = "Return earliest and latest checkpoints for the selected Virtual Protection Group" )] [switch]$checkpointsStats, [Parameter( ParameterSetName = "entityTypes", - Mandatory = $true, + Mandatory, HelpMessage = "Return Valid VPG entityTypes" )] [switch]$entityTypes, [Parameter( ParameterSetName = "failoverCommitPolicies", - Mandatory = $true, + Mandatory, HelpMessage = "Valid Failover Commit Policies" )] [switch]$failoverCommitPolicies, [Parameter( ParameterSetName = "failoverShutdownPolicies", - Mandatory = $true, + Mandatory, HelpMessage = "Valid Failover Shutdown Policies" )] [switch]$failoverShutdownPolicies, [Parameter( ParameterSetName = "priorities", - Mandatory = $true, + Mandatory, HelpMessage = "Valid VPG priorities" )] [switch]$priorities, [Parameter( ParameterSetName = "retentionPolicies", - Mandatory = $true, + Mandatory, HelpMessage = "Valid retention policies" )] [switch]$retentionPolicies, [Parameter( ParameterSetName = "statuses", - Mandatory = $true, + Mandatory, HelpMessage = "Valid VPG statuses" )] [switch]$statuses, [Parameter( ParameterSetName = "subStatuses", - Mandatory = $true, + Mandatory, HelpMessage = "Valid VPG sub statuses" )] [switch]$subStatuses, @@ -160,7 +160,6 @@ function Get-ZertoVpg { ) begin { $baseUri = "vpgs" - $returnObject = @() } Process { @@ -169,14 +168,13 @@ function Get-ZertoVpg { # When called with no parameters, return all values "main" { - $returnObject = Invoke-ZertoRestRequest -uri $baseUri + $uri = $baseUri } # When called with protectionGroupIdentifier, query for each id provided "protectionGroupIdentifier" { - $returnObject = foreach ( $vpgId in $protectionGroupIdentifier ) { - $uri = "{0}/{1}" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri + $uri = foreach ( $vpgId in $protectionGroupIdentifier ) { + "{0}/{1}" -f $baseUri, $vpgId } } @@ -185,7 +183,7 @@ function Get-ZertoVpg { $filter = $false if ( $PSBoundParameters.ContainsKey("startDate") -or $PSBoundParameters.ContainsKey("endDate") ) { $filter = $true - $filterTable = @{} + $filterTable = @{ } foreach ( $param in $PSBoundParameters.GetEnumerator() ) { if ( $param.key -eq "startDate" -or $param.key -eq "endDate") { $filterTable[$param.key] = $param.value @@ -193,21 +191,19 @@ function Get-ZertoVpg { } $filter = Get-ZertoApiFilter -filterTable $filterTable } - $returnObject = foreach ( $id in $protectionGroupIdentifier ) { + $uri = foreach ( $id in $protectionGroupIdentifier ) { if ( $filter ) { - $uri = "{0}/{1}/checkpoints{2}" -f $baseUri, $id, $filter + "{0}/{1}/checkpoints{2}" -f $baseUri, $id, $filter } else { - $uri = "{0}/{1}/checkpoints" -f $baseUri, $id + "{0}/{1}/checkpoints" -f $baseUri, $id } - Invoke-ZertoRestRequest -uri $uri } } # When stats are requested "stats" { - $returnObject = foreach ( $id in $protectionGroupIdentifier ) { - $uri = "{0}/{1}/checkpoints/stats" -f $baseUri, $id - Invoke-ZertoRestRequest -uri $uri + $uri = foreach ( $id in $protectionGroupIdentifier ) { + "{0}/{1}/checkpoints/stats" -f $baseUri, $id } } @@ -215,18 +211,18 @@ function Get-ZertoVpg { "filter" { $filter = Get-ZertoApiFilter -filterTable $PSBoundParameters $uri = "{0}{1}" -f $baseUri, $filter - $returnObject = Invoke-ZertoRestRequest -uri $uri } # Default is to build URI based on ParameterSetName and return results. default { $uri = "{0}/{1}" -f $baseUri, $PSCmdlet.ParameterSetName.ToLower() - $returnObject = Invoke-ZertoRestRequest -uri $uri } } + foreach ($entry in $uri) { + Invoke-ZertoRestRequest -uri $entry + } } End { - return $returnObject } } diff --git a/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 index 39a59e3..13164a1 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 @@ -10,7 +10,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -18,15 +18,15 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, - HelpMessage = "The identifier of the VPG settings object for which information is retrieved." + Mandatory, + HelpMessage = "The identifier of the VPG settings object for which information is retrieved. Please note, this parameter is ONLY available in Zerto version 7.5 and earlier. Attempting to run this switch against a Zerto Virtual Manager version 8.0 or higher result in an error." )] [Parameter( ParameterSetName = "dayOfWeek", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -34,7 +34,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -42,7 +42,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -50,7 +50,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -58,7 +58,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -66,7 +66,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -74,7 +74,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -82,7 +82,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -90,7 +90,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -98,7 +98,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -106,7 +106,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -114,7 +114,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -122,7 +122,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -130,7 +130,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -138,7 +138,7 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( @@ -146,7 +146,15 @@ function Get-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, - Mandatory = $true, + Mandatory, + HelpMessage = "The identifier of the VPG settings object for which information is retrieved." + )] + [Parameter( + ParameterSetName = "ltr", + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + ValueFromRemainingArguments = $true, + Mandatory, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [ValidateNotNullOrEmpty()] @@ -154,99 +162,100 @@ function Get-ZertoVpgSetting { [string[]]$vpgSettingsIdentifier, [Parameter( ParameterSetName = "backup", - Mandatory = $true, - HelpMessage = "Return backup information for VPG identifier specified" + Mandatory, + HelpMessage = "Return backup information for VPG identifier specified. Please note, this parameter is ONLY available in Zerto version 7.5 and earlier. Attempting to run this switch against a Zerto Virtual Manager version 8.0 or higher result in an error." )] [switch]$backup, [Parameter( ParameterSetName = "dayOfWeek", - Mandatory = $true, - HelpMessage = "Get the day of week a backup is scheduled" + Mandatory, + HelpMessage = "Get the day of week a backup is scheduled. Please note, this parameter is ONLY available in Zerto version 7.5 and earlier. Attempting to run this switch against a Zerto Virtual Manager version 8.0 or higher result in an error." )] [switch]$dayOfWeek, [Parameter( ParameterSetName = "retentionPeriod", - Mandatory = $true, - HelpMessage = "Get the retention period for a backup" + Mandatory, + HelpMessage = "Get the retention period for a backup. Please note, this parameter is ONLY available in Zerto version 7.5 and earlier. Attempting to run this switch against a Zerto Virtual Manager version 8.0 or higher result in an error." )] [switch]$retentionPeriod, [Parameter( ParameterSetName = "schedulerPeriod", - Mandatory = $true, - HelpMessage = "Get the backup schedule" + Mandatory, + HelpMessage = "Get the backup schedule. Please note, this parameter is ONLY available in Zerto version 7.5 and earlier. Attempting to run this switch against a Zerto Virtual Manager version 8.0 or higher result in an error." )] [switch]$schedulerPeriod, [Parameter( ParameterSetName = "basic", - Mandatory = $true, + Mandatory, HelpMessage = "Get VPG Basic Settings" )] [switch]$basic, [Parameter( ParameterSetName = "bootGroup", - Mandatory = $true, + Mandatory, HelpMessage = "Get VPG Boot Settings" )] [switch]$bootgroup, [Parameter( ParameterSetName = "journal", - Mandatory = $true, + Mandatory, HelpMessage = "Get VPG Journal Settings" )] [switch]$journal, [Parameter( ParameterSetName = "networks", - Mandatory = $true, + Mandatory, HelpMessage = "Get VPG Network Settings" )] [switch]$networks, [Parameter( ParameterSetName = "priority", - Mandatory = $true, + Mandatory, HelpMessage = "Get VPG Priority Settings" )] [switch]$priority, [Parameter( ParameterSetName = "recovery", - Mandatory = $true, + Mandatory, HelpMessage = "Get VPG Recovery Settings" )] - [switch]$rcovery, + [Alias("rcovery")] + [switch]$recovery, [Parameter( ParameterSetName = "scripting", - Mandatory = $true, + Mandatory, HelpMessage = "Get VPG Recovery Settings" )] [switch]$scripting, [Parameter( ParameterSetName = "vms", - Mandatory = $true, + Mandatory, HelpMessage = "Get all settings for all VMs in a VPG." )] [switch]$vms, [Parameter( ParameterSetName = "vmIdentifier", - Mandatory = $true, + Mandatory, HelpMessage = "Get all settings for selected VM" )] [Parameter( ParameterSetName = "nics", - Mandatory = $true, + Mandatory, HelpMessage = "VM Identifier" )] [Parameter( ParameterSetName = "volumes", - Mandatory = $true, + Mandatory, HelpMessage = "VM Identifier" )] [Parameter( ParameterSetName = "nicIdentifier", - Mandatory = $true, + Mandatory, HelpMessage = "VM Identifier" )] [Parameter( ParameterSetName = "volumeIdentifier", - Mandatory = $true, + Mandatory, HelpMessage = "VM Identifier" )] [ValidateNotNullOrEmpty()] @@ -254,13 +263,13 @@ function Get-ZertoVpgSetting { [string]$vmIdentifier, [Parameter( ParameterSetName = "nics", - Mandatory = $true, + Mandatory, HelpMessage = "Return NIC information for all NICs of the specified VM" )] [switch]$nics, [Parameter( ParameterSetName = "nicIdentifier", - Mandatory = $true, + Mandatory, HelpMessage = "Return NIC information for specified NIC of the specified VM" )] [ValidateNotNullOrEmpty()] @@ -268,18 +277,25 @@ function Get-ZertoVpgSetting { [string]$nicIdentifier, [Parameter( ParameterSetName = "volumes", - Mandatory = $true, + Mandatory, HelpMessage = "Return Volume information for all volumes of the specified VM" )] [switch]$volumes, [Parameter( ParameterSetName = "volumeIdentifier", - Mandatory = $true, + Mandatory, HelpMessage = "Return volume information for the specified volume of the specified VM" )] [ValidateNotNullOrEmpty()] [Alias("volumeId")] - [string]$volumeIdentifier + [string]$volumeIdentifier, + [Parameter( + ParameterSetName = "ltr", + Mandatory, + HelpMessage = "Return LTR information for the specified VPG. Please note, this parameter is ONLY available in Zerto version 8.0 and later. Attempting to run this switch against a Zerto Virtual Manager version 7.5 or lower will result in an error." + )] + [switch]$ltr + ) begin { diff --git a/ZertoApiWrapper/Public/Import-ZertoVmNicSetting.ps1 b/ZertoApiWrapper/Public/Import-ZertoVmNicSetting.ps1 new file mode 100644 index 0000000..bd9a51d --- /dev/null +++ b/ZertoApiWrapper/Public/Import-ZertoVmNicSetting.ps1 @@ -0,0 +1,124 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Import-ZertoVmNicSetting { + [CmdletBinding(SupportsShouldProcess)] + param( + # File to process for import + [Parameter(Helpmessage = "CSV file containing the required VM NIC settings", Mandatory)] + [ValidateNotNullOrEmpty()] + [string] + $InputFile + ) + + begin { + } + + process { + if (-not (Test-Path $InputFile)) { + Write-Error "Unable to find $InputFile. Please check the name and path and try again." -ErrorAction Stop + } elseif ((Get-Item $InputFile).Extension -notmatch '.csv') { + Write-Error "$InputFile does not have a 'csv' extension. Please check the name and path and try again." -ErrorAction Stop + } + $ExpectedHeaders = "VPGName", "VMName", "NicIdentifier", "LiveNetwork", "LiveShouldReplaceMac", "LiveIsDHCP", "LiveIpAddress", "LiveIpSubnetMask", "LiveIpDefaultGateway", "LivePrimaryDns", "LiveSecondayDns", "LiveDnsSuffix", "TestNetwork", "TestShouldReplaceMac", "TestIsDHCP", "TestIpAddress", "TestIpSubnetMask", "TestIpDefaultGateway", "TestPrimaryDns", "TestSecondayDns", "TestDnsSuffix" + $HeaderLine = ((Get-Content -Path $InputFile -First 1).Replace('"', '')).Split(',') + foreach ($header in $ExpectedHeaders) { + if ($header -notin $HeaderLine) { + Write-Error "$InputFile is malformed. Please ensure all headers are present." -ErrorAction Stop + } + } + $ImportData = Import-Csv -Path $InputFile + $VpgsToUpdate = $ImportData.VPGName | Select-Object -Unique + foreach ($Vpg in $VpgsToUpdate) { + $VpgInfo = Get-ZertoVpg -vpgName $Vpg + $VpgIdentifier = $VpgInfo.VpgIdentifier + $RecoveryNetworks = Get-ZertoVirtualizationSite -siteIdentifier $VpgInfo.RecoverySite.Identifier -networks + $NetworkMap = Get-Map -InputObject $RecoveryNetworks -key "VirtualizationNetworkName" -value "NetworkIdentifier" + $VpgVms = Get-ZertoProtectedVm -vpgName $Vpg + $VmMap = Get-Map -InputObject $VpgVms -key "vmName" -value "vmIdentifier" + $VpgSettingsId = New-ZertoVpgSettingsIdentifier -vpgIdentifier $VpgIdentifier + $VmsToUpdate = $ImportData | Where-Object { $_.VPGName -eq $Vpg } + foreach ($vm in $VmsToUpdate) { + if ([string]::IsNullOrWhiteSpace($vm.VpgName) -or + [string]::IsNullOrWhiteSpace($Vm.VMName) -or + [string]::IsNullOrWhiteSpace($Vm.NicIdentifier) -or + [string]::IsNullOrWhiteSpace($Vm.LiveNetwork) -or + [string]::IsNullOrWhiteSpace($Vm.LiveShouldReplaceMac) -or + [string]::IsNullOrWhiteSpace($Vm.TestNetwork) -or + [string]::IsNullOrWhiteSpace($Vm.TestShouldReplaceMac)) { + Write-Error "$($Vm.VMName) does not contain all the required data. Please check the CSV entry for this item and try again. You are required to provide the VPGName, VMName, NicIdentifier, LiveNetwork, and ShouldReplaceMacAddress for each Nic." -ErrorAction Continue + } else { + $uri = "vpgSettings/{0}/vms/{1}" -f $vpgSettingsId, $vmMap[$vm.VMName] + $VmNicSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsId -vmIdentifier $vmMap[$vm.VMName] + foreach ($nic in $VmNicSettings.nics) { + if ($nic.NicIdentifier -eq $vm.NicIdentifier) { + $NicUri = "{0}/nics/{1}" -f $uri, $nic.NicIdentifier + Invoke-ZertoRestRequest -uri $NicUri -Method "DELETE" > $null + $nicSettings = Invoke-ZertoRestRequest -uri $NicUri -Method "GET" + $nicSettings.failover.Hypervisor.NetworkIdentifier = $NetworkMap[$vm.LiveNetwork] + $nicSettings.failover.Hypervisor.ShouldReplaceMacAddress = $vm.LiveShouldReplaceMac + if ($vm.LiveIsDHCP -imatch "true") { + $IpConfig = [PSCustomObject]@{ + IsDhcp = $vm.LiveIsDHCP + PrimaryDns = $vm.LivePrimaryDns + SecondaryDns = $vm.LiveSecondayDns + } + $nicSettings.failover.Hypervisor.IpConfig = $IpConfig + $nicSettings.failover.Hypervisor.DnsSuffix = $vm.LiveDnsSuffix + } elseif (($vm.LiveIsDHCP -imatch "false" -or + [string]::IsNullOrWhiteSpace($vm.LiveIsDHCP)) -and + -not [string]::IsNullOrWhiteSpace($vm.LiveIpAddress)) { + $IpConfig = [PSCustomObject]@{ + IsDhcp = $vm.LiveIsDHCP + StaticIp = $vm.LiveIpAddress + SubnetMask = $vm.LiveIpSubnetMask + Gateway = $vm.LiveIpDefaultGateway + PrimaryDns = $vm.LivePrimaryDns + SecondaryDns = $vm.LiveSecondayDns + } + $nicSettings.failover.Hypervisor.IpConfig = $IpConfig + $nicSettings.failover.Hypervisor.DnsSuffix = $vm.LiveDnsSuffix + } + $nicSettings.failoverTest.Hypervisor.NetworkIdentifier = $NetworkMap[$vm.TestNetwork] + $nicSettings.failoverTest.Hypervisor.ShouldReplaceMacAddress = $vm.TestShouldReplaceMac + if ($vm.TestIsDHCP -imatch "true" ) { + $IpConfig = [PsCustomObject]@{ + IsDhcp = $vm.TestIsDHCP + PrimaryDns = $vm.TestPrimaryDns + SecondaryDns = $vm.TestSecondayDns + } + $nicSettings.failoverTest.Hypervisor.IpConfig = $IpConfig + $nicSettings.failoverTest.Hypervisor.DnsSuffix = $vm.TestDnsSuffix + } elseif (($vm.TestIsDHCP -imatch "false" -or + [string]::IsNullOrWhiteSpace($vm.TestIsDHCP)) -and + -not [string]::IsNullOrWhiteSpace($vm.TestIpAddress)) { + $IpConfig = [PsCustomObject]@{ + IsDhcp = $vm.TestIsDHCP + StaticIp = $vm.TestIpAddress + SubnetMask = $vm.TestIpSubnetMask + Gateway = $vm.TestIpDefaultGateway + PrimaryDns = $vm.TestPrimaryDns + SecondaryDns = $vm.TestSecondayDns + } + $nicSettings.failoverTest.Hypervisor.IpConfig = $IpConfig + $nicSettings.failoverTest.Hypervisor.DnsSuffix = $vm.TestDnsSuffix + } + Write-Verbose "Putting Updated Config for VM: $($vm.name), NIC: $($nic.nicidentifier) in VPG: $Vpg" + if ($PSCmdlet.ShouldProcess($vm.NicIdentifier, "Updating Nic")) { + Invoke-ZertoRestRequest -uri $NicUri -Method "PUT" -Body ($nicSettings | ConvertTo-Json -Depth 10) > $null + } + } + } + } + } + Write-Verbose "Saving updated configuration for VPG: $Vpg" + if ($PSCmdlet.ShouldProcess($Vpg, "Saving Changes")) { + Save-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsId + } + Write-Verbose "Waiting 5 Seconds for Next VPG Update" + Start-Sleep 5 + } + } + + + end { + } +} diff --git a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 index 48a72cc..30675b9 100644 --- a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 @@ -4,7 +4,7 @@ function Import-ZertoVpg { param( [Parameter( HelpMessage = "VPG settings JSON file(s) to import.", - Mandatory = $true, + Mandatory, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] diff --git a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 index 2bca65f..3ce61d2 100644 --- a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 @@ -1,72 +1,169 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> -#TODO - Add ability to installed with root password, Move to Begin, Process, End Format function Install-ZertoVra { - [cmdletbinding( SupportsShouldProcess = $true )] + [cmdletbinding( SupportsShouldProcess )] param( - [Parameter( Mandatory = $true, HelpMessage = "Host name where the VRA is to be installed." )] + [Parameter( + Mandatory, + HelpMessage = "Host name where the VRA is to be installed." + )] [ValidateNotNullOrEmpty()] [string]$hostName, - [Parameter( Mandatory = $true, HelpMessage = "Datastore name where the VRA is to be installed." )] + [Parameter( + Mandatory, + HelpMessage = "Datastore name where the VRA is to be installed." + )] [ValidateNotNullOrEmpty()] [string]$datastoreName, - [Parameter( Mandatory = $true, HelpMessage = "Network name the VRA is to be assigned." )] + [Parameter( + Mandatory, + HelpMessage = "Network name the VRA is to be assigned." + )] [ValidateNotNullOrEmpty()] [string]$networkName, - [Parameter( HelpMessage = "Initial amount of memory to assign to the VRA in GB. Default is 3, Minimum is 1, Maximum is 16" )] + [Parameter( + HelpMessage = "Initial amount of memory to assign to the VRA in GB. Default is 3, Minimum is 1, Maximum is 16" + )] [ValidateRange(1, 16)] [int]$memoryInGB = 3, - [Parameter( HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will assign to the 'default_group'" )] + [Parameter( + HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will assign to the 'default_group'" + )] [ValidateNotNullOrEmpty()] [string]$groupName, - [Parameter( ParameterSetName = "Dhcp", Mandatory = $true, HelpMessage = "Assign a DHCP address to the VRA." )] + [Parameter( + ParameterSetName = "Dhcp", + Mandatory, + HelpMessage = "Assign a DHCP address to the VRA." + )] + [Parameter( + ParameterSetName = "DhcpWithRoot", + Mandatory, + HelpMessage = "Assign a DHCP address to the VRA." + )] [switch]$Dhcp, - [Parameter( ParameterSetName = "StaticIp", Mandatory = $true, HelpMessage = "Static IP address to assign to the VRA." )] - [ValidateScript( {$_ -match [IPAddress]$_ })] + [Parameter( + ParameterSetName = "StaticIp", + Mandatory, + HelpMessage = "Static IP address to assign to the VRA." + )] + [Parameter( + ParameterSetName = "StaticIpWithRoot", + Mandatory, + HelpMessage = "Static IP address to assign to the VRA." + )] + [ValidateScript( { $_ -match [IPAddress]$_ })] [string]$vraIpAddress, - [Parameter( ParameterSetName = "StaticIp", Mandatory = $true, HelpMessage = "Default gateway to assign to the VRA" )] - [ValidateScript( {$_ -match [IPAddress]$_ })] + [Parameter( + ParameterSetName = "StaticIp", + Mandatory, + HelpMessage = "Default gateway to assign to the VRA" + )] + [Parameter( + ParameterSetName = "StaticIpWithRoot", + Mandatory, + HelpMessage = "Default gateway to assign to the VRA" + )] + [ValidateScript( { $_ -match [IPAddress]$_ })] [string]$defaultGateway, - [Parameter( ParameterSetName = "StaticIp", Mandatory = $true, HelpMessage = "Subnetmask to be assigned to the VRA" )] - [ValidateScript( {$_ -match [IPAddress]$_ })] - [string]$subnetMask - + [Parameter( + ParameterSetName = "StaticIp", + Mandatory, + HelpMessage = "Subnetmask to be assigned to the VRA" + )] + [Parameter( + ParameterSetName = "StaticIpWithRoot", + Mandatory, + HelpMessage = "Subnetmask to be assigned to the VRA" + )] + [ValidateScript( { $_ -match [IPAddress]$_ })] + [string]$subnetMask, + [Parameter( + ParameterSetName = "StaticIpWithRoot", + Mandatory, + HelpMessage = "Use this switch to install the VRA using the root password install method." + )] + [Parameter( + ParameterSetName = "DhcpWithRoot", + Mandatory, + HelpMessage = "Use this switch to install the VRA using the root password install method." + )] + [switch]$UseRootCredential, + [Parameter( + ParameterSetName = "StaticIpWithRoot", + Mandatory, + HelpMessage = "The password for the root user of the ESXi host where the VRA is to be installed." + )] + [Parameter( + ParameterSetName = "DhcpWithRoot", + Mandatory, + HelpMessage = "The password for the root user of the ESXi host where the VRA is to be installed." + )] + [ValidateNotNullOrEmpty()] + [securestring]$HostRootPassword ) - # Build the VRA Name. - $vraName = "Z-VRA-{0}" -f $hostName - # 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 - $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 - # Build the JSON object through an Ordered Hashtable. - $vraBasic = [ordered]@{} - $vraBasic['DatastoreIdentifier'] = $datastoreIdentifier.toString() - if ($PSBoundParameters.ContainsKey('groupName')) { - $vraBasic['GroupName'] = $groupName - } - $vraBasic['HostIdentifier'] = $hostIdentifier.toString() - $vraBasic['MemoryInGB'] = $memoryInGB - $vraBasic['NetworkIdentifier'] = $networkIdentifier.toString() - $vraBasic['UsePublicKeyInsteadOfCredentials'] = $true - $vraBasicNetwork = [ordered]@{} - if ( $PSCmdlet.ParameterSetName -eq "StaticIp" ) { - $vraBasicNetwork['DefaultGateway'] = $defaultGateway.toString() - $vraBasicNetwork['SubnetMask'] = $subnetMask.toString() - $vraBasicNetwork['VraIPAddress'] = $vraIpAddress.toString() - $vraBasicNetwork['VraIPConfigurationTypeApi'] = "Static" + begin { + + } + Process { + # Build the VRA Name. + $vraName = "Z-VRA-{0}" -f $hostName + # 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 = (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 + if ($datastoreIdentifier.count -gt 1) { + $hostDevices = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -devices -hostIdentifier $hostIdentifier + $datastoreIdentifier = foreach ($identifier in $datastoreIdentifier) { + if ($identifier -in $hostDevices.DatastoreIdentifier) { + $identifier + } + } + if ($datastoreIdentifier.count -gt 1) { + Write-Error "Datastore $datastoreName has more than one identifier associated with it on the specified host. Please review and try again." + Break + } + } + + # Build the JSON object through an Ordered Hashtable. + $vraBasic = [ordered]@{ } + $vraBasic['DatastoreIdentifier'] = $datastoreIdentifier.toString() + if ($PSBoundParameters.ContainsKey('groupName')) { + $vraBasic['GroupName'] = $groupName + } + $vraBasic['HostIdentifier'] = $hostIdentifier.toString() + $vraBasic['MemoryInGB'] = $memoryInGB + $vraBasic['NetworkIdentifier'] = $networkIdentifier.toString() + $vraBasic['UsePublicKeyInsteadOfCredentials'] = $true + $vraBasicNetwork = [ordered]@{ } + if ( $PSCmdlet.ParameterSetName -eq "StaticIp" -or $PSCmdlet.ParameterSetName -eq "StaticIpWithRoot") { + $vraBasicNetwork['DefaultGateway'] = $defaultGateway.toString() + $vraBasicNetwork['SubnetMask'] = $subnetMask.toString() + $vraBasicNetwork['VraIPAddress'] = $vraIpAddress.toString() + $vraBasicNetwork['VraIPConfigurationTypeApi'] = "Static" + } else { + $vraBasicNetwork['VraIPConfigurationTypeApi'] = "Dhcp" + } + $vraBasic['VraNetworkDataApi'] = $vraBasicNetwork + if ($PSCmdlet.ParameterSetName -eq "StaticIpWithRoot" -or $PSCmdlet.ParameterSetName -eq "DhcpWithRoot") { + $HostRootCredential = [pscredential]::new('root', $HostRootPassword) + $vraBasic['UsePublicKeyInsteadOfCredentials'] = $false + $vraBasic['HostRootPassword'] = $HostRootCredential.GetNetworkCredential().Password + } + + # Leverage WhatIf functionality to see what might happen, if WhatIf is not specified, attempt to install. + if ($PSCmdlet.ShouldProcess($hostName)) { + Invoke-ZertoRestRequest -uri "vras" -method POST -body $($vraBasic | ConvertTo-Json) + } } else { - $vraBasicNetwork['VraIPConfigurationTypeApi'] = "Dhcp" + Write-Error "Host $hostName already has a VRA installed. Aborting Install Call" } - $vraBasic['VraNetworkDataApi'] = $vraBasicNetwork + } + + End { - # Leverage WhatIf functionality to see what might happen, if WhatIf is not specified, attempt to install. - if ($PSCmdlet.ShouldProcess("Preforming operation 'Install-Vra' on Host $hostName with the following data \n $($vraBasic | convertto-json)")) { - Invoke-ZertoRestRequest -uri "vras" -method POST -body $($vraBasic | ConvertTo-Json) - } - } else { - Write-Error "Host $hostName already has a VRA installed. Aborting Install Call" } } diff --git a/ZertoApiWrapper/Public/Invoke-ZARestRequest.ps1 b/ZertoApiWrapper/Public/Invoke-ZARestRequest.ps1 new file mode 100644 index 0000000..52aab99 --- /dev/null +++ b/ZertoApiWrapper/Public/Invoke-ZARestRequest.ps1 @@ -0,0 +1,48 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Invoke-ZARestRequest { + [cmdletbinding()] + param( + # Parameter help description + [Parameter( + Mandatory, + Helpmessage = "URI endpoint to be utilized. When submitting the URI, only the endpoint needs to be submitted. Please review the help documentation for examples." + )] + [ValidateNotNullOrEmpty()] + [string]$uri, + [Parameter( + Helpmessage = "API method to be used. GET, PUT, POST, or DELETE. Refer to documentation for the API endpoint to ensure the correct method is being used. If unspecified, defaults to GET" + )] + [ValidateSet("GET", "PUT", "POST", "DELETE")] + [string]$method = "GET", + [Parameter( + Helpmessage = "Body to be submitted to the REST API endpoint. This needs to be submitted in JSON format" + )] + [ValidateNotNullOrEmpty()] + [string]$body + + ) + # While the API can use XML or JSON, this module is built on JSON functionality. Currently forcing all + # content types and language to JSON. + [string]$contentType = "application/json" + + # Check to see if the required variables are present and currently valid + if ( -not ((Test-Path variable:script:zaLastActionTime) -and (Test-Path variable:script:zaHeaders)) ) { + Throw "Zerto Analytics Connection does not Exist. Please run Connect-ZertoAnalytics first to establish a connection" + } elseif ( (Test-Path variable:script:zaHeaders) -and $([datetime]$script:zaLastActionTime).addMinutes(60) -lt $(Get-Date) ) { + Throw "Authorization Token has Expired. Please re-authorize to the Zerto Analytics Portal" + } else { + # Update the last action time and submit the request based on PS Version. + Set-Variable -Name zaLastActionTime -Scope Script -Value $(Get-Date).Ticks + $submittedUri = "https://analytics.api.zerto.com/v2/{0}" -f $uri + if ($PSVersionTable.PSVersion.Major -ge 6) { + Invoke-RestMethod -Uri $submittedUri -Method $method -Body $body -Headers $Script:zaHeaders -ContentType $contentType -TimeoutSec 100 + } else { + # With PS 5, you cannot ship a $null body, check for $body variable and select correct Invoke request. + if ([String]::IsNullOrEmpty($body)) { + Invoke-RestMethod -Uri $submittedUri -Method $method -Headers $Script:zaHeaders -ContentType $contentType -TimeoutSec 100 + } else { + Invoke-RestMethod -Uri $submittedUri -Method $method -Headers $Script:zaHeaders -ContentType $contentType -TimeoutSec 100 -Body $body + } + } + } +} diff --git a/ZertoApiWrapper/Public/Invoke-ZertoEvacuateVra.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoEvacuateVra.ps1 new file mode 100644 index 0000000..d01ae9e --- /dev/null +++ b/ZertoApiWrapper/Public/Invoke-ZertoEvacuateVra.ps1 @@ -0,0 +1,62 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Invoke-ZertoEvacuateVra { + [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = "VraIdentifier")] + param ( + # HostName Option + [Parameter( + Mandatory, + HelpMessage = "Name of the Host to Evacuate", + ParameterSetName = "HostName" + )] + [ValidateNotNullOrEmpty()] + [String]$HostName, + # VRA Option + [Parameter( + Mandatory, + HelpMessage = "Name of the VRA to Evacuate", + ParameterSetName = "VraName" + )] + [ValidateNotNullOrEmpty()] + [String]$VraName, + # VRAIdentifier Option + [Parameter( + Mandatory, + HelpMessage = "Identifier of the VRA to be evacuated", + ParameterSetName = "VraIdentifier", + ValueFromPipelineByPropertyName, + ValueFromPipeline + )] + [Alias("VraId", "Identifier")] + [ValidateNotNullOrEmpty()] + [String]$VraIdentifier + ) + + begin { + + } + + process { + switch ($PSCmdlet.ParameterSetName) { + "HostName" { + $VraName = "Z-VRA-" + $HostName + Invoke-ZertoEvacuateVra -VraName $VraName + } + + "VraName" { + $VraIdentifier = (Get-ZertoVra -vraName $VraName).VraIdentifier + Invoke-ZertoEvacuateVra -VraIdentifier $VraIdentifier + } + + "VraIdentifier" { + $Uri = "vras/{0}/changerecoveryvra/execute" -f $VraIdentifier + if ($PSCmdlet.ShouldProcess($VraIdentifier, "Evacuating VRA with Identifier:")) { + Invoke-ZertoRestRequest -Uri $Uri -Method "POST" + } + } + } + } + + end { + + } +} diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index 5eb5500..013a50c 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -4,7 +4,7 @@ function Invoke-ZertoFailover { param( #TODO - Refactor? [Parameter( - Mandatory = $true, + Mandatory, HelpMessage = "Name of the VPG to Failover" )] [ValidateNotNullOrEmpty()] @@ -54,7 +54,7 @@ function Invoke-ZertoFailover { Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop } $baseUri = "vpgs/{0}/failover" -f $vpgId - $body = @{} + $body = @{ } # Setup Required Defaults $body['commitpolicy'] = $commitPolicy $body['TimeToWaitBeforeShutdownInSec'] = $timeToWaitBeforeShutdownInSec @@ -76,7 +76,7 @@ function Invoke-ZertoFailover { $vpgVmInformation = Get-ZertoProtectedVm -vpgName $vpgName [System.Collections.ArrayList]$vmIdentifiers = @() foreach ( $name in $vmName ) { - $selectedVm = $vpgVmInformation | Where-Object {$_.VmName.toLower() -eq $name.toLower()} + $selectedVm = $vpgVmInformation | Where-Object { $_.VmName.toLower() -eq $name.toLower() } if ($null -eq $selectedVm) { Write-Error "VM: $name NOT found in VPG $vpgName. Check the name and try again." -ErrorAction Stop } elseif ($vmIdentifiers.Contains($selectedVm.vmIdentifier.toString())) { diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 index cbd5250..cf91f81 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 @@ -4,7 +4,7 @@ function Invoke-ZertoFailoverCommit { param( [Parameter( HelpMessage = "Name(s) of the VPG(s) to commit.", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName, diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 index fc6b92f..4391d65 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 @@ -4,7 +4,7 @@ function Invoke-ZertoFailoverRollback { param( [Parameter( HelpMessage = "Name(s) of VPG(s) to roll back from failing over", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName diff --git a/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 index 81ee866..8e5c351 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 @@ -4,7 +4,7 @@ function Invoke-ZertoForceSync { param( [Parameter( HelpMessage = "Name(s) of VPG(s) to force sync", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 index 8c7a9a3..a63bb98 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 @@ -1,25 +1,60 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Invoke-ZertoMove { - [CmdletBinding( DefaultParameterSetName = "main", SupportsShouldProcess = $true )] + [CmdletBinding( DefaultParameterSetName = "id", SupportsShouldProcess = $true )] param( [Parameter( + ParameterSetName = 'name', HelpMessage = "Name(s) of the VPG(s) you want to move.", - Mandatory = $true + Mandatory + )] + [Parameter( + ParameterSetName = 'commitName', + HelpMessage = "Name(s) of the VPG(s) you want to move.", + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName, [Parameter( + ParameterSetName = 'id', + HelpMessage = "ID(s) of the VPG(s) you want to move.", + Mandatory, + ValueFromPipelineByPropertyName + )] + [Parameter( + ParameterSetName = 'commitId', + HelpMessage = "ID(s) of the VPG(s) you want to move.", + Mandatory, + ValueFromPipelineByPropertyName + )] + [ValidateNotNullOrEmpty()] + [guid[]]$vpgIdentifier, + [Parameter( + ParameterSetName = 'commitName', HelpMessage = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. 'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. 'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. - Default is the Site Settings setting." + Default is the Site Settings setting.", + Mandatory + )] + [Parameter( + ParameterSetName = 'commitId', + HelpMessage = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. + 'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. + 'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. + Default is the Site Settings setting.", + Mandatory )] [ValidateSet("Rollback", "Commit", "None")] [string]$commitPolicy, [Parameter( + ParameterSetName = 'commitName', HelpMessage = "The amount of time, in seconds, the Move is in a 'Before Commit' state, before performing the commitPolicy setting. If omitted, the site settings default will be applied." )] - # Min 5 Minutes, Max 24 Hours, Default 1 Hour. + [Parameter( + ParameterSetName = 'commitId', + HelpMessage = "The amount of time, in seconds, the Move is in a 'Before Commit' state, before performing the commitPolicy setting. If omitted, the site settings default will be applied." + )] + # Min 5 Minutes, Max 24 Hours, Default Site Settigns. [ValidateRange(300, 86400)] [Int]$commitPolicyTimeout, [Parameter( @@ -27,15 +62,11 @@ function Invoke-ZertoMove { )] [switch]$forceShutdown, [Parameter( - ParameterSetName = "disableReverseProtection", - HelpMessage = "Do not enable reverse protection. The VPG definition is kept with the status Needs Configuration and the reverse settings in the VPG definition are not set.", - Mandatory = $true + HelpMessage = "Do not enable reverse protection. The VPG definition is kept with the status Needs Configuration and the reverse settings in the VPG definition are not set." )] [switch]$disableReverseProtection, [Parameter( - ParameterSetName = "keepSourceVms", - HelpMessage = "Prevent the protected virtual machines from being deleted in the protected site. Using this setting disables reverse protection.", - Mandatory = $true + HelpMessage = "Prevent the protected virtual machines from being deleted in the protected site. Using this setting disables reverse protection." )] [switch]$keepSourceVms, [Parameter( @@ -46,53 +77,51 @@ function Invoke-ZertoMove { begin { $baseUri = "vpgs" - $body = [ordered]@{} - #TODO - use a foreach loop to populate the body without all the if statments + $body = @{ + forceShutdown = $forceShutdown.IsPresent + ContinueOnPreScriptFailure = $ContinueOnPreScriptFailure.IsPresent + keepSourceVms = $keepSourceVms.IsPresent + reverseProtection = -not $disableReverseProtection.IsPresent + } + + if ( $keepSourceVms.IsPresent -and -not $disableReverseProtection.IsPresent ) { + Write-Verbose 'Disabling reverse protection as keepSourceVms requires it' + $body['reverseProtection'] = $false + } + if ($PSBoundParameters.ContainsKey('commitPolicy')) { $body['commitPolicy'] = $commitPolicy - } - if ($PSBoundParameters.ContainsKey('commitPolicyTimeout')) { - $body['commitPolicyTimeout'] = $commitPolicyTimeout - } - if ($PSBoundParameters.ContainsKey('forceShutdown')) { - $body['forceShutdown'] = $true - } else { - $body['forceShutdown'] = $false - } - if ($PSBoundParameters.ContainsKey('ContinueOnPreScriptFailure')) { - $body['ContinueOnPreScriptFailure'] = $true - } else { - $body['ContinueOnPreScriptFailure'] = $false - } - switch ($PSCmdlet.ParameterSetName) { - "disableReverseProtection" { - $body['reverseProtection'] = $false - $body['keepSourceVms'] = $false - } - - "keepSourceVms" { - $body['reverseProtection'] = $false - $body['keepSourceVms'] = $true - } - - "main" { - $body['reverseProtection'] = $true - $body['keepSourceVms'] = $false + if ($PSBoundParameters.ContainsKey('commitPolicyTimeout')) { + $body['commitPolicyTimeout'] = $commitPolicyTimeout } } } process { - foreach ($name in $vpgName) { - $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier - if ( -not $vpgId ) { - Write-Error "VPG: $name not found. Please check the name and try again. Skipping" - } else { - $uri = "{0}/{1}/move" -f $baseUri, $vpgId - if ($PSCmdlet.ShouldProcess("Moving VPG: $name wiht settings: $($body | convertto-json)")) { - Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + + switch ($PSCmdlet.ParameterSetName) { + { $_ -in 'name', 'commitName' } { + $vpgIds = foreach ($name in $vpgName) { + $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier + if ( -not $vpgId ) { + Write-Error "VPG: '$name' not found. Please check the name and try again. Skipping" + } else { + Write-Verbose "VPG: $name, ID: $vpgId" + $vpgId + } } } + + { $_ -in 'id', 'commitId' } { + $vpgIds = $vpgIdentifier + } + } + + foreach ($thisId in $vpgIds) { + $uri = "{0}/{1}/move" -f $baseUri, $thisId + if ($PSCmdlet.ShouldProcess("Moving VPG: $thisId with settings: $($body | ConvertTo-Json)")) { + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + } } } diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 index f524af1..81f5f79 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 @@ -1,30 +1,41 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Invoke-ZertoMoveCommit { - [cmdletbinding(SupportsShouldProcess = $true)] + [cmdletbinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Main")] param( [Parameter( HelpMessage = "Name(s) of the VPG(s) to commit.", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName, [Parameter( - HelpMessage = "Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False" + HelpMessage = "Use this switch to reverse protect the VPG(s) to the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation.", + ParameterSetName = 'ReverseProtect', + Mandatory + )] [switch]$reverseProtection, [Parameter( - HelpMessage = "Use this switch to keep the source VMs. If not set, they will be destroyed." + HelpMessage = "Use this switch to keep the source VMs at the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation.", + ParameterSetName = 'KeepSource', + Mandatory )] [switch]$keepSourceVms ) begin { $baseUri = "vpgs" - $body = @{} - if ($reverseProtection) { - $body["ReverseProtection"] = $true - } elseif ($keepSourceVms) { - $body["KeepSourceVms"] = $true + $body = @{ } + Switch ($PSCmdlet.ParameterSetName){ + 'KeepSource' { + $body["KeepSourceVms"] = $true + $body["ReverseProtection"] = $false + } + + 'ReverseProtect' { + $body["ReverseProtection"] = $true + $body["KeepSourceVms"] = $false + } } } diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 index b1d7e24..36728dd 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 @@ -4,7 +4,7 @@ function Invoke-ZertoMoveRollback { param( [Parameter( HelpMessage = "Name(s) of VPG(s) to roll back from failing over", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName diff --git a/ZertoApiWrapper/Public/Invoke-ZertoRestRequest.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoRestRequest.ps1 new file mode 100644 index 0000000..93d77e4 --- /dev/null +++ b/ZertoApiWrapper/Public/Invoke-ZertoRestRequest.ps1 @@ -0,0 +1,110 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Invoke-ZertoRestRequest { + [cmdletbinding()] + param( + # Parameter help description + [Parameter( + Helpmessage = "API method to be used. GET, PUT, POST, or DELETE. Refer to documentation for the API endpoint to ensure the correct method is being used. If unspecified, defaults to GET" + )] + [ValidateSet("GET", "PUT", "POST", "DELETE")] + [string]$method = "GET", + [Parameter( + Mandatory, + Helpmessage = "URI endpoint to be utilized. When submitting the URI, only the endpoint needs to be submitted. Please review the help documentation for examples." + )] + [ValidateNotNullOrEmpty()] + [string]$uri, + [Parameter( + Helpmessage = "Body to be submitted to the REST API endpoint. This needs to be submitted in JSON format" + )] + [ValidateNotNullOrEmpty()] + [string]$body, + [Parameter( + Helpmessage = "PSCredential object. This is ONLY used when authenticating with the ZVM. No other endpoints require this and generally is not used." + )] + [PSCredential]$credential, + [Parameter( + Helpmessage = "Use this switch if you would like the request headers returned along with the body. Useful for troubleshooting to get HTTP error codes." + )] + [switch]$returnHeaders + ) + # API version. Currently this is locked at v1 in all versions of Zerto. Should this change, will look + # at making this as parameter to be selected during function call. + $apiVersion = "v1" + # While the API can use XML or JSON, this module is built on JSON functionality. Currently forcing all + # content types and language to JSON. + $contentType = "application/json" + $callerErrorActionPreference = $ErrorActionPreference + # If the ZVM server and Port not defined, Stop Call + if ( -not ((Test-Path variable:script:zvmServer) -and (Test-Path variable:script:zvmPort)) ) { + Throw "Zerto Connection does not Exist. Please run Connect-ZertoServer first to establish a connection" + } + + # 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) -and $Script:Reconnect -eq $False ) { + Throw "Authorization Token has Expired. Please re-authorize to the Zerto Virtual Manager" + } 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 { + public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { + return true; + } +} +'@ + 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 + + } + # 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 + #} + } +} diff --git a/ZertoApiWrapper/Public/New-ZertoPairingToken.ps1 b/ZertoApiWrapper/Public/New-ZertoPairingToken.ps1 new file mode 100644 index 0000000..2eca94d --- /dev/null +++ b/ZertoApiWrapper/Public/New-ZertoPairingToken.ps1 @@ -0,0 +1,23 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function New-ZertoPairingToken { + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + + ) + + begin { + + } + + process { + $uri = "peersites/generatetoken" + $body = @{ } + if ($PSCmdlet.ShouldProcess("Obtaining Pairing token from $script:zvmServer")) { + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + } + } + + end { + + } +} diff --git a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index a4885f5..d46b818 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -1,10 +1,10 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function New-ZertoVpg { - [cmdletbinding(SupportsShouldProcess = $true)] + [cmdletbinding(SupportsShouldProcess = $true, DefaultParameterSetName = "recoveryHostDatastore")] param( [Parameter( HelpMessage = "Name of the VPG", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$vpgName, @@ -20,89 +20,89 @@ function New-ZertoVpg { [int]$journalHistoryInHours = 24, [Parameter( HelpMessage = "Name(s) of the VM(s) to be protected.", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$protectedVm, [Parameter( HelpMessage = "Name of the site where the VM(s) will be recovered", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$recoverySite, [Parameter( HelpMessage = "Name of the cluster where the VM(s) will be recovered.", ParameterSetName = "recoveryClusterDatastore", - Mandatory = $true + Mandatory )] [Parameter( HelpMessage = "Name of the cluster where the VM(s) will be recovered.", ParameterSetName = "recoveryClusterDatastoreCluster", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$recoveryCluster, [Parameter( HelpMessage = "Name of the host where the VM(s) will be recovered.", ParameterSetName = "recoveryHostDatastore", - Mandatory = $true + Mandatory )] [Parameter( HelpMessage = "Name of the host where the VM(s) will be recovered.", ParameterSetName = "recoveryHostDatastoreCluster", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$recoveryHost, [Parameter( HelpMessage = "Name of the resource pool where the VM(s) will be recovered.", ParameterSetName = "recoveryResourcePoolDatastore", - Mandatory = $true + Mandatory )] [Parameter( HelpMessage = "Name of the resource pool where the VM(s) will be recovered.", ParameterSetName = "recoveryResourcePoolDatastoreCluster", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$recoveryResourcePool, [Parameter( HelpMessage = "Name of the datastore where the VM(s), Volume(s), and Journal(s) will reside.", ParameterSetName = "recoveryClusterDatastore", - Mandatory = $true + Mandatory )] [Parameter( HelpMessage = "Name of the datastore where the VM(s), Volume(s), and Journal(s) will reside.", ParameterSetName = "recoveryHostDatastore", - Mandatory = $true + Mandatory )] [Parameter( HelpMessage = "Name of the datastore where the VM(s), Volume(s), and Journal(s) will reside.", ParameterSetName = "recoveryResourcePoolDatastore", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$datastore, [Parameter( HelpMessage = "Name of the datastore cluster where the VM(s), Volume(s), and Journal(s) will reside.", ParameterSetName = "recoveryClusterDatastoreCluster", - Mandatory = $true + Mandatory )] [Parameter( HelpMessage = "Name of the datastore cluster where the VM(s), Volume(s), and Journal(s) will reside.", ParameterSetName = "recoveryHostDatastoreCluster", - Mandatory = $true + Mandatory )] [Parameter( HelpMessage = "Name of the datastore cluster where the VM(s), Volume(s), and Journal(s) will reside.", ParameterSetName = "recoveryResourcePoolDatastoreCluster", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$datastoreCluster, [Parameter( HelpMessage = "Name of folder at recovery location where the recovered virtual machine(s) will be created.", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$recoveryFolder, @@ -132,13 +132,13 @@ function New-ZertoVpg { [String]$zorg, [Parameter( HelpMessage = "Name of the network to use during a Failover Live \ Move VPG operation.", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [String]$recoveryNetwork, [Parameter( HelpMessage = "Name of the network to use during a Failover Test operation", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$testNetwork, @@ -164,64 +164,63 @@ function New-ZertoVpg { begin { # Create an identifiers table, and start converting names to identifiers. - $identifiersTable = @{} - $identifiersTable['recoverySiteIdentifier'] = $(Get-ZertoPeerSite -peerName $recoverySite).siteIdentifier + $identifiersTable = @{ } + $identifiersTable['recoverySiteIdentifier'] = Get-ZertoVirtualizationSite | Where-Object { $_.VirtualizationSiteName -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 - $identifiersTable['folderIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -folders | Where-Object {$_.FolderName -like $recoveryFolder}).folderIdentifier + $identifiersTable['failoverNetworkIdentifier'] = $peerSiteNetworks | Where-Object { $_.VirtualizationNetworkName -like $recoveryNetwork } | Select-Object -ExpandProperty NetworkIdentifier + $identifiersTable['testNetworkIdentifier'] = $peerSiteNetworks | Where-Object { $_.VirtualizationNetworkName -like $testNetwork } | Select-Object -ExpandProperty NetworkIdentifier + $identifiersTable['folderIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -folders | Where-Object { $_.FolderName -like $recoveryFolder }).folderIdentifier if ($PSBoundParameters.ContainsKey("zorg")) { - $identifiersTable['zorgIdentifier'] = $(Get-ZertoZorg | Where-Object {$_.ZorgName -like $zorg}).ZorgIdentifier + $identifiersTable['zorgIdentifier'] = $(Get-ZertoZorg | Where-Object { $_.ZorgName -like $zorg }).ZorgIdentifier } if ($PSBoundParameters.ContainsKey("serviceProfile")) { - $identifiersTable['serviceProfileIdentifier'] = $(Get-ZertoServiceProfile -siteIdentifier $identifiersTable['recoverySiteIdentifier'] | Where-Object {$_.ServiceProfileName -like $serviceProfile}).serviceProfileIdentifier + $identifiersTable['serviceProfileIdentifier'] = $(Get-ZertoServiceProfile -siteIdentifier $identifiersTable['recoverySiteIdentifier'] | Where-Object { $_.ServiceProfileName -like $serviceProfile }).serviceProfileIdentifier } if ($PSBoundParameters.ContainsKey('journalDatastore')) { - $identifiersTable['journalDatastore'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object {$_.DatastoreName -like $journalDatastore}).DatastoreIdentifier + $identifiersTable['journalDatastore'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object { $_.DatastoreName -like $journalDatastore }).DatastoreIdentifier } # 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['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object {$_.DatastoreName -like $datastore}).DatastoreIdentifier + $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['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 } "recoveryHostDatastore" { - $identifiersTable['recoveryHostIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hosts | Where-Object {$_.VirtualizationHostName -like $recoveryHost}).HostIdentifier - $identifiersTable['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object {$_.DatastoreName -like $datastore}).DatastoreIdentifier + $identifiersTable['recoveryHostIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hosts | Where-Object { $_.VirtualizationHostName -like $recoveryHost }).HostIdentifier + $identifiersTable['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object { $_.DatastoreName -like $datastore }).DatastoreIdentifier } "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['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object {$_.DatastoreName -like $datastore}).DatastoreIdentifier + $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 } } $unprotectedVms = Get-ZertoUnprotectedVm $protectedVms = Get-ZertoProtectedVm # Create array of VM identifiers - $vmIdentifiers = @() $vmIdentifiers = foreach ($vm in $protectedVm) { # If the VM is unprotected, get the identifier - $vmIdentifier = $unprotectedVms | Where-Object {$_.vmName -like $vm} | Select-Object -ExpandProperty vmIdentifier + $vmIdentifier = $unprotectedVms | Where-Object { $_.vmName -like $vm } | Select-Object -ExpandProperty vmIdentifier # If the VM is not unprotected, check the protected VMs if ( -not $vmIdentifier) { # Get all identifiers to test if the VM is eligible to be a member of an additional VPG - $results = $protectedVms | Where-Object {$_.VmName -like $vm} | Select-Object -ExpandProperty vmIdentifier + $results = $protectedVms | Where-Object { $_.VmName -like $vm } | Select-Object -ExpandProperty vmIdentifier # If VM is currently a member of 3 VPGs, skip it. If it cannot be found, skip it. Otherwise, set the identifier if ($results.count -eq 3) { Write-Warning "$vm is already a part of 3 VPGs and cannot be part of an additional VPG. Skipping $vm" @@ -296,11 +295,11 @@ function New-ZertoVpg { "recoveryHostDatastoreCluster" { $baseSettings.Recovery.DefaultDatastoreClusterIdentifier = $identifiersTable['datastoreClusterIdentifier'] - $baseSettings.Recovery.DefaultHostIdentifier = $identifiersTable['hostIdentifier'] + $baseSettings.Recovery.DefaultHostIdentifier = $identifiersTable['recoveryHostIdentifier'] } "recoveryHostDatastore" { - $baseSettings.Recovery.DefaultHostIdentifier = $identifiersTable['hostIdentifier'] + $baseSettings.Recovery.DefaultHostIdentifier = $identifiersTable['recoveryHostIdentifier'] $baseSettings.Recovery.DefaultDatastoreIdentifier = $identifiersTable['datastoreIdentifier'] } @@ -314,13 +313,7 @@ function New-ZertoVpg { $baseSettings.Recovery.DefaultDatastoreIdentifier = $identifiersTable['datastoreIdentifier'] } } - # If only 1 VM is selected, force VMs settings to be an array. - If ($vmIdentifiers.count -eq 1) { - $basesettings.Vms = @() - $baseSettings.Vms += $vmIdentifiers - } else { - $baseSettings.Vms = $vmIdentifiers - } + $basesettings.Vms += $vmIdentifiers if ($identifiersTable.ContainsKey('journalDatastore')) { $baseSettings.Journal.DatastoreIdentifier = $identifiersTable['journalDatastore'] } diff --git a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 index 06150d2..53efea7 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 @@ -5,7 +5,7 @@ function New-ZertoVpgSettingsIdentifier { [Parameter( HelpMessage = "Identifier of the VPG to create a VPG settings identifier. If a vpgIdentifier is not provided, a new VPG settings object is created without any configured settings. This would be used for creating a new VPG from scratch.", ParameterSetName = "existingVpg", - Mandatory = $true, + Mandatory, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] @@ -15,7 +15,7 @@ function New-ZertoVpgSettingsIdentifier { [Parameter( HelpMessage = "Use this switch when creating a vpgSettingsIdentifier for a new VPG", ParameterSetName = "newVpg", - Mandatory = $true + Mandatory )] [switch]$newVpg ) diff --git a/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 index 0d818e9..64e4289 100644 --- a/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 @@ -10,7 +10,7 @@ function Remove-ZertoPeerSite { ParameterSetName = "siteIdentifier", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [Alias("siteId")] @@ -20,7 +20,7 @@ function Remove-ZertoPeerSite { ParameterSetName = "peerSiteName", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$peerSiteName, @@ -29,9 +29,9 @@ function Remove-ZertoPeerSite { ParameterSetName = "hostName", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, - Mandatory = $true + Mandatory )] - [ValidateScript( {$_ -match [IPAddress]$_ })] + [ValidateScript( { $_ -match [IPAddress]$_ })] [string[]]$hostName, [Parameter( HelpMessage = "Specify this switch to Keep the target replica disks for any VPGs replicating between the sites as the VPGs will be deleted by unpairing the sites. If this switch is not used, the target replica disks will be deleted" @@ -41,7 +41,7 @@ function Remove-ZertoPeerSite { begin { $baseUri = "peersites" - $body = @{} + $body = @{ } if ( $keepTargetDisks ) { $body['IsKeepTargetDisks'] = $true } else { @@ -78,4 +78,4 @@ function Remove-ZertoPeerSite { end { # Nothing to do } -} \ No newline at end of file +} diff --git a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 index 5e453fb..e389705 100644 --- a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 @@ -3,7 +3,7 @@ function Remove-ZertoVpg { [cmdletbinding( SupportsShouldProcess = $true, DefaultParameterSetName = "vpgIdentifier" )] param( [Parameter( - Mandatory = $true, + Mandatory, ParameterSetName = "vpgName", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, @@ -12,7 +12,7 @@ function Remove-ZertoVpg { [ValidateNotNullOrEmpty()] [string[]]$vpgName, [Parameter( - Mandatory = $true, + Mandatory, ParameterSetName = "vpgIdentifier", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, @@ -33,7 +33,7 @@ function Remove-ZertoVpg { begin { $baseUri = "vpgs" - $body = @{} + $body = @{ } if ($keepRecoveryVolumes) { $body['KeepRecoveryVolumes'] = $True } else { diff --git a/ZertoApiWrapper/Public/Remove-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/Remove-ZertoVpgSettingsIdentifier.ps1 new file mode 100644 index 0000000..186e477 --- /dev/null +++ b/ZertoApiWrapper/Public/Remove-ZertoVpgSettingsIdentifier.ps1 @@ -0,0 +1,26 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Remove-ZertoVpgSettingsIdentifier { + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + # Settings Identifier to Remove + [Parameter(HelpMessage = "VpgSettingsIdentifier to Delete", Mandatory)] + [ValidateNotNullOrEmpty()] + [string[]] + $vpgSettingsIdentifier + ) + + begin { + } + + process { + foreach ($id in $vpgSettingsIdentifier) { + if ($PSCmdlet.ShouldProcess($id)) { + $uri = "vpgSettings/{0}" -f $id + Invoke-ZertoRestRequest -uri $uri -method "DELETE" + } + } + } + + end { + } +} diff --git a/ZertoApiWrapper/Public/Remove-ZertoVpgVm.ps1 b/ZertoApiWrapper/Public/Remove-ZertoVpgVm.ps1 new file mode 100644 index 0000000..2af5029 --- /dev/null +++ b/ZertoApiWrapper/Public/Remove-ZertoVpgVm.ps1 @@ -0,0 +1,53 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Remove-ZertoVpgVm { + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")] + param ( + [Parameter( + Mandatory, + HelpMessage = "Name of the VPG that contains the VM you wish to remove", + ParameterSetName = "VpgName" + )] + [ValidateNotNullOrEmpty()] + [String]$VpgName, + [Parameter( + Mandatory, + HelpMessage = "Name of VM(s) to remove from the VPG" + )] + [ValidateNotNullOrEmpty()] + [String[]]$Vm + ) + + begin { + + } + + process { + $VpgData = Get-ZertoVpg -vpgName $VpgName + if (-not $VpgData) { + Write-Error "Unable to find Vpg with name $VpgName. Please check your parameters and try again." -ErrorAction Stop + } else { + $protectedVms = Get-ZertoProtectedVm -vpgName $VpgData.VpgName + } + $VmIdentifiers = foreach ($machine in ($vm | Select-Object -Unique)) { + if ($machine -in $protectedVms.VmName) { + $protectedVms.Where( { $_.VmName -like $machine }) | Select-Object -ExpandProperty VmIdentifier + } else { + Write-Warning "Virtual Machine: '$machine' is not found in Vpg: '$VpgName'. Check your parameters. Skipping $machine" + } + } + if ($VmIdentifiers.Count -gt 0 -and $PSCmdlet.ShouldProcess(($Vm | Select-Object -Unique), "Removing VM(s): $($Vm | Select-Object -Unique) from Vpg $VpgName")) { + $vpgSettingsIdentifier = New-ZertoVpgSettingsIdentifier -vpgIdentifier $VpgData.VpgIdentifier + foreach ($identifier in $VmIdentifiers) { + $url = "vpgSettings/{0}/vms/{1}" -f $vpgSettingsIdentifier, $identifier + Invoke-ZertoRestRequest -uri $url -method DELETE + } + Save-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier + } else { + Write-Warning "No VMs found to remove. Please check your parameters and try again." + } + } + + end { + + } +} diff --git a/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 index 24e1c8f..a1b10d7 100644 --- a/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 @@ -4,7 +4,7 @@ function Resume-ZertoVpg { param( [Parameter( HelpMessage = "Name(s) of VPG(s) to resume replication", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName diff --git a/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 b/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 index 64c9127..3f7fed8 100644 --- a/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 +++ b/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 @@ -6,17 +6,25 @@ function Save-ZertoVpgSetting { param( [Parameter( HelpMessage = "VpgSettings Identifier to save", - Mandatory = $true, + Mandatory, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] [ValidateNotNullOrEmpty()] - [Alias("vpgSettingsId")] + [Alias("sid", "settingsIdentifier", "vpgSettingsId")] [string]$vpgSettingsIdentifier ) - $baseUri = "vpgsettings/{0}/commit" -f $vpgSettingsIdentifier - if ($PSCmdlet.ShouldProcess("Commiting VPG Settings with Settigns identifier $vpgSettingsIdentifier")) { - Invoke-ZertoRestRequest -uri $baseUri -method "POST" + Begin { + } + + Process { + $baseUri = "vpgsettings/{0}/commit" -f $vpgSettingsIdentifier + if ($PSCmdlet.ShouldProcess("Commiting VPG Settings with Settigns identifier $vpgSettingsIdentifier")) { + Invoke-ZertoRestRequest -uri $baseUri -method "POST" + } + } + + End { } } diff --git a/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 b/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 index 1969177..725dd5b 100644 --- a/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 +++ b/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 @@ -5,7 +5,7 @@ function Set-ZertoAlert { [Parameter( ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, - Mandatory = $true, + Mandatory, HelpMessage = "Alert identifier(s) to be dismissed or undismissed." )] [ValidateNotNullOrEmpty()] @@ -13,13 +13,13 @@ function Set-ZertoAlert { [string[]]$alertId, [Parameter( ParameterSetName = "dismiss", - Mandatory = $true, + Mandatory, HelpMessage = "Will dismiss the selected alert." )] [switch]$dismiss, [Parameter( ParameterSetName = "undismiss", - Mandatory = $true, + Mandatory, HelpMessage = "Will undismiss the selected alert." )] [switch]$undismiss diff --git a/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 b/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 index 6ce7e32..90fdd47 100644 --- a/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 +++ b/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 @@ -3,7 +3,7 @@ function Set-ZertoLicense { [cmdletbinding( SupportsShouldProcess = $true )] param ( [Parameter( - Mandatory = $true, + Mandatory, HelpMessage = "License Key to apply to the Zerto Virtual Manager" )] [ValidateNotNullOrEmpty()] @@ -12,11 +12,11 @@ function Set-ZertoLicense { begin { $baseUri = "license" - $body = @{"LicenseKey" = $licenseKey} + $body = @{"LicenseKey" = $licenseKey } } 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" } } @@ -24,4 +24,4 @@ function Set-ZertoLicense { end { # Nothing to do } -} \ No newline at end of file +} diff --git a/ZertoApiWrapper/Public/Set-ZertoUserCredential.ps1 b/ZertoApiWrapper/Public/Set-ZertoUserCredential.ps1 new file mode 100644 index 0000000..110be91 --- /dev/null +++ b/ZertoApiWrapper/Public/Set-ZertoUserCredential.ps1 @@ -0,0 +1,35 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Set-ZertoUserCredential { + [cmdletbinding( + SupportsShouldProcess, + ConfirmImpact = 'High' + )] + param( + [Parameter( + HelpMessage = "PSCredential Object that contains the username and password for the updated credentials.", + Mandatory + )] + [pscredential]$UserCredential + ) + + begin { + + } + + process { + $uri = '/localsite/virtualizationsettings' + $body = @{ + Credentials = @{ + UserName = $UserCredential.UserName + Password = $UserCredential.GetNetworkCredential().Password + } + } + if ( $PSCmdlet.ShouldProcess( $script:zvmServer, "Updating hypervisor service account credentials" )) { + Invoke-ZertoRestRequest -uri $uri -Method PUT -body ($body | ConvertTo-Json) + } + } + + end { + + } +} diff --git a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 index 1678c8b..17f4919 100644 --- a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 @@ -4,7 +4,7 @@ function Start-ZertoCloneVpg { param( [Parameter( HelpMessage = "Name of the VPG you wish to clone.", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$vpgName, @@ -27,25 +27,32 @@ function Start-ZertoCloneVpg { ) begin { + + } + + process { $baseUri = "vpgs" $vpgInfo = Get-ZertoVpg -name $vpgName if ( -not $vpgInfo ) { Write-Error "VPG: $vpgName could not be found. Please check the name and try again." } $vpgIdentifier = $vpgInfo.vpgIdentifier + $body = @{ } if ( $PSBoundParameters.ContainsKey('datastoreName') ) { $recoverysiteIdentifier = $vpgInfo.recoverysite.identifier $recoverySiteDatastores = Get-ZertoVirtualizationSite -siteIdentifier $recoverysiteIdentifier -datastores - $datastoreIdentifier = $($recoverySiteDatastores | Where-Object {$_.datastoreName -like $datastoreName}).DatastoreIdentifier + $datastoreIdentifier = $($recoverySiteDatastores | Where-Object { $_.datastoreName -like $datastoreName }).DatastoreIdentifier if ( -not $datastoreIdentifier ) { Write-Error "Datastore: $datastoreName is not a valid datastore. Please check the name and try again." -ErrorAction Stop + } else { + $body['DatastoreIdentifier'] = $datastoreIdentifier } } if ( $PSBoundParameters.ContainsKey('vmName') ) { $vpgVmInformation = Get-ZertoProtectedVm -vpgName $vpgName [System.Collections.ArrayList]$vmIdentifiers = @() foreach ( $name in $vmName ) { - $selectedVm = $vpgVmInformation | Where-Object {$_.VmName.toLower() -eq $name.toLower()} + $selectedVm = $vpgVmInformation | Where-Object { $_.VmName.toLower() -eq $name.toLower() } if ($null -eq $selectedVm) { Write-Error "VM: $name NOT found in VPG $vpgName. Check the name and try again." -ErrorAction Stop } elseif ($vmIdentifiers.Contains($selectedVm.vmIdentifier.toString())) { @@ -55,32 +62,20 @@ function Start-ZertoCloneVpg { } } $body['VmIdentifiers'] = $vmIdentifiers - if ($checkpointIdentifier) { - $body['CheckpointIdentifier'] = $checkpointIdentifier - } } - } - - process { - $uri = "{0}/{1}/CloneStart" -f $baseUri, $vpgIdentifier - $body = [ordered]@{} if ( $PSBoundParameters.ContainsKey('checkpointIdentifier') ) { $body['checkpointId'] = $checkpointIdentifier } - if ( $datastoreIdentifier ) { - $body['DatastoreIdentifier'] = $datastoreIdentifier - } - if ( $vmIdentifiers ) { - $body['VmIdentifiers'] = $vmIdentifiers - } Write-Verbose $body + $uri = "{0}/{1}/CloneStart" -f $baseUri, $vpgIdentifier if ($PSCmdlet.ShouldProcess("Clone Vpg")) { Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST" + Write-Verbose "Call Submitted to $uri" + Write-Verbose "With the following information: $($body | ConvertTo-Json)" } } end { - Write-Verbose "Call Submitted to $uri" - Write-Verbose "With the following information: $($body | ConvertTo-Json)" + } } diff --git a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 index ee044e3..9c3512d 100644 --- a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 @@ -4,7 +4,7 @@ function Start-ZertoFailoverTest { param( [Parameter( HelpMessage = "Name of VPG to failover test", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$vpgName, @@ -27,11 +27,12 @@ function Start-ZertoFailoverTest { if ( -not $vpgIdentifier) { Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop } + $body = @{ } if ( $PSBoundParameters.ContainsKey('vmName') ) { $vpgVmInformation = Get-ZertoProtectedVm -vpgName $vpgName - [System.Collections.ArrayList]$vmIdentifiers = @() + $vmIdentifiers = [System.Collections.Generic.List[string]]::new() foreach ( $name in $vmName ) { - $selectedVm = $vpgVmInformation | Where-Object {$_.VmName.toLower() -eq $name.toLower()} + $selectedVm = $vpgVmInformation | Where-Object { $_.VmName.toLower() -eq $name.toLower() } if ($null -eq $selectedVm) { Write-Error "VM: $name NOT found in VPG $vpgName. Check the name and try again." -ErrorAction Stop } elseif ($vmIdentifiers.Contains($selectedVm.vmIdentifier.toString())) { diff --git a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 index 6e78ade..f0d4bb5 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 @@ -4,7 +4,7 @@ function Stop-ZertoCloneVpg { param( [Parameter( HelpMessage = "Name of the VPG to stop cloning", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string]$vpgName diff --git a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 index babb190..9b5774e 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 @@ -4,7 +4,7 @@ function Stop-ZertoFailoverTest { param( [Parameter( HelpMessage = "Name(s) of VPG(s) to stop testing.", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName, @@ -21,7 +21,7 @@ function Stop-ZertoFailoverTest { begin { $baseUri = "vpgs" - $body = @{"FailoverTestSuccess" = $failoverTestSuccess; "FailoverTestSummary" = $failoverTestSummary} + $body = @{"FailoverTestSuccess" = $failoverTestSuccess; "FailoverTestSummary" = $failoverTestSummary } } process { diff --git a/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 index c590859..09278e2 100644 --- a/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 @@ -4,7 +4,7 @@ function Suspend-ZertoVpg { param( [Parameter( HelpMessage = "Name(s) of VPG(s) to pause replication", - Mandatory = $true + Mandatory )] [ValidateNotNullOrEmpty()] [string[]]$vpgName diff --git a/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 b/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 index b62f332..bd5c701 100644 --- a/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 @@ -3,7 +3,7 @@ function Uninstall-ZertoVra { [cmdletbinding()] param( [Parameter( - Mandatory = $true, + Mandatory, HelpMessage = "Host Name attached to the VRA to be removed." )] [ValidateNotNullOrEmpty()] diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index 6ae1461..51251ea 100644 --- a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml +++ b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml @@ -150,7 +150,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Add-ZertoPeerSite.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Add-ZertoPeerSite.md Zerto REST API Peer Site End Point Documentation @@ -262,7 +262,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Checkpoint-ZertoVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Checkpoint-ZertoVpg.md Zerto REST API VPG End Point Documentation @@ -421,7 +421,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Connect-ZertoServer.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Connect-ZertoServer.md Zerto REST API Session End Point Documentation @@ -492,7 +492,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Disconnect-ZertoServer.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Disconnect-ZertoServer.md Zerto REST API Session End Point Documentation @@ -746,7 +746,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Edit-ZertoVra.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Edit-ZertoVra.md Zerto REST API VRA End Point Documentation @@ -903,7 +903,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/Export-ZertoVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Export-ZertoVpg.md Zerto REST API VPG Settings End Point Documentation @@ -1325,7 +1325,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoAlert.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoAlert.md Zerto REST API Alerts End Point Documentation @@ -1420,7 +1420,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoDatastore.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoDatastore.md Zerto REST API Datastore Information End Point Documentation @@ -1916,7 +1916,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoEvent.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoEvent.md Zerto REST API Events End Point Documentation @@ -1979,7 +1979,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoLicense.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoLicense.md Zerto REST API License Information @@ -2066,7 +2066,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoLocalSite.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoLocalSite.md Zerto REST API Local Site End Point Documentation @@ -2310,7 +2310,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoPeerSite.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoPeerSite.md Zerto REST API Peer Site End Point Documentation @@ -2663,7 +2663,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoProtectedVm.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoProtectedVm.md Zerto REST API Protected VMs End Point Documentation @@ -2926,7 +2926,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoRecoveryReport.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoRecoveryReport.md Zerto REST API Recovery Report End Point Documentation @@ -3399,7 +3399,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoResourcesReport.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoResourcesReport.md Zerto REST API Resources Report End Point Documentation @@ -3514,7 +3514,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoServiceProfile.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoServiceProfile.md Zerto REST API Service Profile End Point Documentation @@ -3782,7 +3782,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoTask.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoTask.md Zerto REST API Task End Point Documentation @@ -3845,7 +3845,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoUnprotectedVm.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoUnprotectedVm.md Zerto REST API Virtualization Sites End Point Documentation @@ -4332,7 +4332,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVirtualizationSite.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVirtualizationSite.md Zerto REST API Virtualization Sites End Point Documentation @@ -4530,7 +4530,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVolume.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVolume.md Zerto REST API Volumes End Point Documentation @@ -5221,7 +5221,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVpg.md Zerto REST API VPG End Point Documentation @@ -6035,7 +6035,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVpgSetting.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVpgSetting.md Zerto REST API VPG Settings End Point Documentation @@ -6401,7 +6401,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVra.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVra.md Zerto REST API VRA End Point Documentation @@ -6496,7 +6496,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoZorg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoZorg.md Zerto REST API ZOrg End Point Documentation @@ -6584,7 +6584,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertpZsspSession.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertpZsspSession.md Zerto REST API ZSSP Session End Point Documentation @@ -6672,7 +6672,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/Import-ZertoVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Import-ZertoVpg.md Zerto REST API VPG Settings End Point Documentation @@ -7089,7 +7089,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Install-ZertoVra.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Install-ZertoVra.md Zerto REST API VRA End Point Documentation @@ -7386,7 +7386,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailover.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailover.md Zerto REST API VPG End Point Documentation @@ -7504,7 +7504,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailoverCommit.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailoverCommit.md Zerto REST API VPG End Point Documentation @@ -7592,7 +7592,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailoverRollback.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailoverRollback.md Zerto REST API VPG End Point Documentation @@ -7680,7 +7680,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoForceSync.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoForceSync.md Zerto REST API VPG End Point Documentation @@ -8046,7 +8046,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoMove.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoMove.md Zerto REST API VPG End Point Documentation @@ -8360,7 +8360,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoMoveRollback.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoMoveRollback.md Zerto REST API VPG End Point Documentation @@ -10299,7 +10299,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/New-ZertoVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/New-ZertoVpg.md Zerto REST API VPG Settings End Point Documentation @@ -10488,7 +10488,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/New-ZertoVpgSettingsIdentifier.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/New-ZertoVpgSettingsIdentifier.md Zerto REST API VPG Settings End Point Documentation @@ -10761,7 +10761,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Remove-ZertoPeerSite.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Remove-ZertoPeerSite.md Zerto REST API Peer Site End Point Documentation @@ -11033,7 +11033,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Remove-ZertoVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Remove-ZertoVpg.md Zerto REST API VPG End Point Documentation @@ -11121,7 +11121,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Resume-ZertoVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Resume-ZertoVpg.md Zerto REST API VPG End Point Documentation @@ -11255,7 +11255,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md Zerto REST API VPG Settings End Point Documentation @@ -11479,7 +11479,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Set-ZertoAlert.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Set-ZertoAlert.md Zerto REST API Alerts End Point Documentation @@ -11613,7 +11613,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Set-ZertoLicense.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Set-ZertoLicense.md Zerto REST API License Information @@ -11819,7 +11819,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Start-ZertoCloneVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Start-ZertoCloneVpg.md Zerto REST API VPG End Point Documentation @@ -12001,7 +12001,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Start-ZertoFailoverTest.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Start-ZertoFailoverTest.md Zerto REST API VPG End Point Documentation @@ -12135,7 +12135,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Stop-ZertoCloneVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Stop-ZertoCloneVpg.md Zerto REST API VPG End Point Documentation @@ -12317,7 +12317,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Stop-ZertoFailoverTest.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Stop-ZertoFailoverTest.md Zerto REST API VPG End Point Documentation @@ -12405,7 +12405,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Suspend-ZertoVpg.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Suspend-ZertoVpg.md Zerto REST API VPG End Point Documentation @@ -12493,7 +12493,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Uninstall-ZertoVra.md + https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Uninstall-ZertoVra.md Zerto REST API VRA End Point Documentation @@ -12501,4 +12501,4 @@ - \ No newline at end of file + diff --git a/ZertoApiWrapper/ZertoApiWrapper.psd1 b/ZertoApiWrapper/ZertoApiWrapper.psd1 index c86a32b..44754ec 100644 --- a/ZertoApiWrapper/ZertoApiWrapper.psd1 +++ b/ZertoApiWrapper/ZertoApiWrapper.psd1 @@ -33,7 +33,7 @@ Description = 'PowerShell Core Wrapper Module for Zerto Virtual Manager API' # Minimum version of the PowerShell engine required by this module - PowerShellVersion = '6.0.0' + PowerShellVersion = '5.1.0' # Name of the PowerShell host required by this module # PowerShellHostName = '' @@ -69,7 +69,7 @@ # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - FunctionsToExport = 'Add-ZertoPeerSite', 'Checkpoint-ZertoVpg', 'Connect-ZertoServer', 'Disconnect-ZertoServer', 'Edit-ZertoVra', 'Export-ZertoVpg', 'Get-ZertoAlert', 'Get-ZertoDatastore', 'Get-ZertoEvent', 'Get-ZertoLicense', 'Get-ZertoLocalSite', 'Get-ZertoPeerSite', 'Get-ZertoProtectedVm', 'Get-ZertoRecoveryReport', 'Get-ZertoResourcesReport', 'Get-ZertoServiceProfile', 'Get-ZertoTask', 'Get-ZertoUnprotectedVm', 'Get-ZertoVirtualizationSite', 'Get-ZertoVolume', 'Get-ZertoVpg', 'Get-ZertoVpgSetting', 'Get-ZertoVra', 'Get-ZertoZorg', 'Get-ZertoZsspSession', 'Import-ZertoVpg', 'Install-ZertoVra', 'Invoke-ZertoFailover', 'Invoke-ZertoFailoverCommit', 'Invoke-ZertoFailoverRollback', 'Invoke-ZertoForceSync', 'Invoke-ZertoMove', 'Invoke-ZertoMoveCommit', 'Invoke-ZertoMoveRollback', 'New-ZertoVpg', 'New-ZertoVpgSettingsIdentifier', 'Remove-ZertoPeerSite', 'Remove-ZertoVpg', 'Resume-ZertoVpg', 'Save-ZertoVpgSettings', 'Set-ZertoAlert', 'Set-ZertoLicense', 'Start-ZertoCloneVpg', 'Start-ZertoFailoverTest', 'Stop-ZertoCloneVpg', 'Stop-ZertoFailoverTest', 'Suspend-ZertoVpg', 'Uninstall-ZertoVra' + FunctionsToExport = '*' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 46201e1..b20a9a2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,89 +5,101 @@ name: $(TeamProject)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) -# Trigger CI on commit to master and develop branches +# Trigger CI on commit to master branch trigger: branches: include: - master - - develop - - TestingBranch + - PowerShellBackPort + - Refactor-Build # Trigger CI on pull requests to master and develop branches pr: - master - - develop - - TestingBranch jobs: - # Windows Build Job - - job: Build_PS_Win2016 + # Windows PowerShell 5.1 Build Job + - job: Build_PS_Windows timeoutInMinutes: 10 cancelTimeoutInMinutes: 2 pool: - vmImage: vs2017-win2016 + 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: '**/TestResults.xml' - testRunTitle: 'PS_Win2016' - 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 + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 + 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: "**/BuiltTestResults.xml" + testRunTitle: "PSCore_Win2016_Built" + displayName: "Publish Test Results" + condition: always() # Linux Build Job - - job: Build_PSCore_Ubuntu1604 + - job: Build_PSCore_Ubuntu timeoutInMinutes: 10 cancelTimeoutInMinutes: 2 pool: - vmImage: ubuntu-16.04 + 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: '**/TestResults.xml' - testRunTitle: 'PSCore_Ubuntu1604' - 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@1 + displayName: "Publish Data" + inputs: + artifactName: "ReleaseData" + targetPath: ./publish + condition: always() # MacOS Build Job - - job: Build_PSCore_MacOS1013 + - job: Build_PSCore_MacOS timeoutInMinutes: 10 cancelTimeoutInMinutes: 2 pool: - vmImage: xcode9-macos10.13 + 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: '**/TestResults.xml' - testRunTitle: 'PSCore_MacOS1013' - 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() 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 diff --git a/docs/Add-ZertoPeerSite.md b/docs/Add-ZertoPeerSite.md index c05f0ef..72d82c2 100644 --- a/docs/Add-ZertoPeerSite.md +++ b/docs/Add-ZertoPeerSite.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Add-ZertoPeerSite.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Add-ZertoPeerSite.md schema: 2.0.0 --- @@ -13,7 +13,8 @@ Pairs the current Zerto Virtual Manager to the target Zerto Virtual Manager ## SYNTAX ``` -Add-ZertoPeerSite [-targetHost] [[-targetPort] ] [-WhatIf] [-Confirm] [] +Add-ZertoPeerSite [-targetHost] [[-targetPort] ] [-token ] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -23,10 +24,17 @@ Pairs the current Zerto Virtual Manager to the target Zerto Virtual Manager by l ### Example 1 ```powershell -PS C:\> Add-ZertoPeerSite -targetHost "192.168.2.100" -targetPort "9081" +PS C:\> Add-ZertoPeerSite -targetHost "192.168.2.100" ``` -Pairs the current Zerto Virtual Manager to the Zerto Virtual Manager at IP address 192.168.2.100. +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 prior to version 7.5 + +### Example 2 +```powershell +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 over Port 9071. Use this method when pairing Zerto Virtual Managers that are version 7.5 or later. ## PARAMETERS @@ -61,6 +69,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -token +The generated token from the destination site. Note: This is only supported when both sites support pairing authentication. This was implemented to support ZVR 7.5 and later. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Confirm Prompts you for confirmation before running the cmdlet. diff --git a/docs/Add-ZertoVpgVm.md b/docs/Add-ZertoVpgVm.md new file mode 100644 index 0000000..5997286 --- /dev/null +++ b/docs/Add-ZertoVpgVm.md @@ -0,0 +1,138 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Add-ZertoVpgVm.md +schema: 2.0.0 +--- + +# Add-ZertoVpgVm + +## SYNOPSIS +Adds one or more virtual machines to an existing VPG. A VPG Settings Identifier will be returned for use in either further customization of the VPG or passed to the `Save-ZertoVpgSetting` command to commit the changes. + +## SYNTAX + +### VpgName (Default) +``` +Add-ZertoVpgVm -VpgName -Vm [-WhatIf] [-Confirm] [] +``` + +### VpgSettingsIdentifier +``` +Add-ZertoVpgVm -vpgSettingsIdentifier -Vm [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Adds one or more virtual machines to an existing VPG. A VPG Settings Identifier will be returned for use in either further customization of the VPG or passed to the `Save-ZertoVpgSetting` command to commit the changes. + +Internal logic to the function will only process unique items and ensure that VMs meet requirements to replicate to the target site. These requirements include not currently a member of the specified VPG, not currently replicating to the target site, and not a member of 3 or more VPGs. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Add-ZertoVpgVm -VpgSettingsIdentifier $vpgSettingsIdentifier -Vm "VM 1", "Vm 2" +``` + +Adds "VM 1" and "VM 2" to the Vpg with VpgSettingsIdentifer specified in `$VpgSettingsIdentifier`. This variable was obtained via other functions that create and return a Vpg Settings Identifier. The Vpg Settings Identifier passed into the function will be returned. + +### Example 2 +```powershell +PS C:\> Add-ZertoVpgVm -VpgName "My Vpg" -Vm "VM 1", "Vm 2" +``` + +Adds "VM 1" and "VM 2" to the Vpg named "My Vpg". In this case, a new Vpg Settings Identifier will be created and returned. + +## PARAMETERS + +### -Vm +Name of VM(s) to add to the VPG + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -VpgName +Target VPG Name to Add the VM + +```yaml +Type: String +Parameter Sets: VpgName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgSettingsIdentifier +Vpg Settings Identifier + +```yaml +Type: String +Parameter Sets: VpgSettingsIdentifier +Aliases: sid, settingsIdentifier, vpgSettingsId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +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 + +### System.String + +## OUTPUTS + +### System.Object + +## NOTES + +## RELATED LINKS +[Adding VMs to a VPG Settings Object](https://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20(ZVM)%20-%20vSphere%20Online%20Help/content/zvr_apis/vpg_management_api.htm?tocpath=ZVR%20RESTful%20APIs%7CZerto%20APIs%7C_____20#statusapis_4057192544_1358357) diff --git a/docs/Checkpoint-ZertoVpg.md b/docs/Checkpoint-ZertoVpg.md index 3c08107..7951d3c 100644 --- a/docs/Checkpoint-ZertoVpg.md +++ b/docs/Checkpoint-ZertoVpg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Checkpoint-ZertoVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Checkpoint-ZertoVpg.md schema: 2.0.0 --- @@ -13,7 +13,7 @@ Add a tagged checkpoint to a specified VPG ## SYNTAX ``` -Checkpoint-ZertoVpg [-vpgName] [-checkpointName] [] +Checkpoint-ZertoVpg [-vpgName] [-checkpointName] [] ``` ## DESCRIPTION @@ -49,14 +49,14 @@ Accept wildcard characters: False Name of the VPG to tag. ```yaml -Type: String +Type: String[] Parameter Sets: (All) Aliases: Required: True Position: 0 Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` diff --git a/docs/Connect-ZertoAnalytics.md b/docs/Connect-ZertoAnalytics.md new file mode 100644 index 0000000..0c30a0d --- /dev/null +++ b/docs/Connect-ZertoAnalytics.md @@ -0,0 +1,61 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Connect-ZertoAnalytics.md +schema: 2.0.0 +--- + +# Connect-ZertoAnalytics + +## SYNOPSIS +All requests to the server, apart from the request to authenticate, must contain a security token which is provided on successful authentication. +In order to authenticate, the user sends myZerto credentials (user/password). + +## SYNTAX + +``` +Connect-ZertoAnalytics [-credential] [] +``` + +## DESCRIPTION +All requests to the server, apart from the request to authenticate, must contain a security token which is provided on successful authentication. +In order to authenticate, the user sends myZerto credentials (user/password). Once this call has been completed successfully, the header authentication token will be stored as a variable and automatically passed during future calls to the Zerto Analytics platform. This token will automatically expire after 60 minutes of inactivity and need to be reauthorized by calling this function again. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Connect-ZertoAnalytics -credential $myCredential +``` + +Connects to the Zerto Analytics site and gets a Bearer Authorization token that is automatically stored as a variable for future calls to the Zerto Analytics REST API. This token will automatically expire after 60 minutes of inactivity and need to be reauthorized by calling this function again. + +## PARAMETERS + +### -credential +PSCredential Object containing username and password authorized for the Zerto Analytics site + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Authentication](https://docs.api.zerto.com/#/Authentication/post_v2_auth_token) diff --git a/docs/Connect-ZertoServer.md b/docs/Connect-ZertoServer.md index 810bdb0..9a08e8d 100644 --- a/docs/Connect-ZertoServer.md +++ b/docs/Connect-ZertoServer.md @@ -1,110 +1,135 @@ ---- -external help file: ZertoApiWrapper-help.xml -Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/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] [-credential] [-zertoPort ] [-AutoReconnect] + [-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. + +### 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: 1 +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: Named +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) diff --git a/docs/Copy-ZertoVpg.md b/docs/Copy-ZertoVpg.md new file mode 100644 index 0000000..9981fcf --- /dev/null +++ b/docs/Copy-ZertoVpg.md @@ -0,0 +1,127 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Copy-ZertoVpg.md +schema: 2.0.0 +--- + +# Copy-ZertoVpg + +## SYNOPSIS +Copy an existing VPG settings object to create a new VPG with the same settings. New VMs must be added to the copied VPG. + +## SYNTAX + +``` +Copy-ZertoVpg [-SourceVpgName] [-NewVpgName] [-VMs] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Copy an existing VPG settings object to create a new VPG with the same settings. New VMs must be added to the copied VPG. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Copy-ZertoVpg -SourceVpgName 'MyVpg' -NewVpgName 'MyNewVpg' -VMs 'VmToAdd01' +``` + +Copies the settings of 'MyVpg' into a new VPG 'MyNewVpg' adding one VM, 'VmToAdd01' + +### Example 2 +```powershell +PS C:\> Copy-ZertoVpg -SourceVpgName 'MyVpg' -NewVpgName 'MyNewVpg' -VMs 'VmToAdd01', 'VmToAdd02' +``` + +Copies the settings of 'MyVpg' into a new VPG 'MyNewVpg' adding two VMs, 'VmToAdd01' and 'VmToAdd02' + +## PARAMETERS + +### -NewVpgName +Name to assign the newly created VPG + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SourceVpgName +Name of the VPG to clone + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -VMs +Name of VMs to add to the VPG + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Clone VPG API Endpoint 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.119.html%23) diff --git a/docs/Disconnect-ZertoServer.md b/docs/Disconnect-ZertoServer.md index 814d8cc..9cb7188 100644 --- a/docs/Disconnect-ZertoServer.md +++ b/docs/Disconnect-ZertoServer.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Disconnect-ZertoServer.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Disconnect-ZertoServer.md schema: 2.0.0 --- diff --git a/docs/Edit-ZertoVra.md b/docs/Edit-ZertoVra.md index be40e81..a34332a 100644 --- a/docs/Edit-ZertoVra.md +++ b/docs/Edit-ZertoVra.md @@ -1,20 +1,20 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Edit-ZertoVra.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Edit-ZertoVra.md schema: 2.0.0 --- # Edit-ZertoVra ## SYNOPSIS -Updates a VRA with updated settings +Updates a VRA with updated settings. Use of this function will cause a reboot of the associated VRA. ## SYNTAX ``` Edit-ZertoVra -vraIdentifier [-groupName ] [-vraIpAddress ] [-defaultGateway ] - [-subnetMask ] [-WhatIf] [-Confirm] [] + [-subnetMask ] [-HostRootPassword ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -24,6 +24,8 @@ It is possible to update the Bandwidth group with the -groupName setting. If the It is possible to update the static IP address, default gateway, or subnetmask. +This function can be used if the VRA was installed with host credentials to update the password to connect to the host if it has changed. + It is suggested that you use Get-ZertoVra to get the vraIdentifer parameter. ## EXAMPLES @@ -49,13 +51,20 @@ PS C:\>Edit-ZertoVra -vraIdentifier $vraIdentifier -vraIpAddress "192.168.1.101" Updates the VRA IP address to 192.168.1.101, subnet mask to 255.255.252.0, and default gateway to 192.168.1.1 -### Example 3 +### Example 4 ```powershell PS C:\>Edit-ZertoVra -vraIdentifier $vraIdentifier -defaultGateway "192.168.1.1" ``` Updates the VRA default gateway to 192.168.1.1 +### Example 5 +```powershell +PS C:\>Edit-ZertoVra -HostRootPassword $HostRootPassword +``` + +Updates the VRA default gateway to 192.168.1.1 + ## PARAMETERS ### -defaultGateway @@ -89,6 +98,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -HostRootPassword +Updated ESXi host root password. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -subnetMask Subnetmask to be assigned to the VRA diff --git a/docs/Export-ZertoVmNicSetting.md b/docs/Export-ZertoVmNicSetting.md new file mode 100644 index 0000000..fe9268b --- /dev/null +++ b/docs/Export-ZertoVmNicSetting.md @@ -0,0 +1,79 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Export-ZertoVmNicSettings.md +schema: 2.0.0 +--- + +# Export-ZertoVmNicSetting + +## SYNOPSIS +Queries VPGs and associated Virtual Machines to export all protected virtual machine NIC settings to a Comma Separated Value (CSV) file. + +## SYNTAX + +``` +Export-ZertoVmNicSetting [[-VpgName] ] [-OutputFile] [] +``` + +## DESCRIPTION +Queries VPGs and associated Virtual Machines to export all protected virtual machine NIC settings to a Comma Separated Value (CSV) file. This file can be used with the Import-ZertoVmNicSetting function to bulk update. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Export-ZertoVmNicSetting -OutputFile "C:\ZertoInfo\VMNicSettings.csv" +``` + +Exports VM Nic Settings for ALL Virtual Protection Groups to a file located at "C:\ZertoInfo\VMNicSettings.csv" + +### Example 2 +```powershell +PS C:\> Export-ZertoVmNicSetting -OutputFile "C:\ZertoInfo\VMNicSettings.csv" -VpgName "Exchange", "Support Forum" +``` + +Exports VM Nic Settings for Exchange and Support Forum Virtual Protection Groups to a file located at "C:\ZertoInfo\VMNicSettings.csv" + +## PARAMETERS + +### -OutputFile +Output file information + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -VpgName +Vpg(s) to export. If no VPG was named, all data will be exported. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Export-ZertoVpg.md b/docs/Export-ZertoVpg.md index 52e6dc5..8a1ee4c 100644 --- a/docs/Export-ZertoVpg.md +++ b/docs/Export-ZertoVpg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/Export-ZertoVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Export-ZertoVpg.md schema: 2.0.0 --- diff --git a/docs/Get-ZAAlert.md b/docs/Get-ZAAlert.md new file mode 100644 index 0000000..ae37647 --- /dev/null +++ b/docs/Get-ZAAlert.md @@ -0,0 +1,125 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAAlert.md +schema: 2.0.0 +--- + +# Get-ZAAlert + +## SYNOPSIS +Retrieve information about all existing alerts. + +## SYNTAX + +### zOrg (Default) +``` +Get-ZAAlert [-zOrgIdentifier ] [-limitTo ] [] +``` + +### alertId +``` +Get-ZAAlert -alertIdentifier [] +``` + +## DESCRIPTION +Retrieve information about all existing alerts. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAAlert +``` + +Returns all alerts. + +### Example 2 +```powershell +PS C:\> Get-ZAAlert -limitTo 10 +``` + +Returns 10 alerts. + +### Example 3 +```powershell +PS C:\> Get-ZAAlert -zOrgIdentifier "1234-5678-9012" +``` + +Returns all alerts for the zOrg with Identifier "1234-5678-9012". + +### Example 4 +```powershell +PS C:\> Get-ZAAlert -zOrgIdentifier "1234-5678-9012" -limitTo 10 +``` + +Returns 10 alerts for the zOrg with Identifier "1234-5678-9012". + +### Example 3 +```powershell +PS C:\> Get-ZAAlert -alertId "1234-5678-9012" +``` + +Returns one alert with identifier "1234-5678-9012". + +## PARAMETERS + +### -alertIdentifier +The VPG Idnetifier + +```yaml +Type: String +Parameter Sets: alertId +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -limitTo +The maximum number of alerts to return. + +```yaml +Type: Int32 +Parameter Sets: zOrg +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the alert list. +If the ZORG identifier is omitted, a list of all the alerts is retrieved. + +```yaml +Type: String +Parameter Sets: zOrg +Aliases: + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Alerts](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_alerts) +[Zerto Analytics REST API Endpoint for Alerts by Identifier](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_alerts__alertIdentifier_) diff --git a/docs/Get-ZADatastore.md b/docs/Get-ZADatastore.md new file mode 100644 index 0000000..eb9f7f2 --- /dev/null +++ b/docs/Get-ZADatastore.md @@ -0,0 +1,123 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZATask.md +schema: 2.0.0 +--- + +# Get-ZADatastore + +## SYNOPSIS + +Get a list of datastore/s, filtered by site. Enter a site identifier only to get the list of all datastores. Enter a site identifier and cluster identifier to get a list of datastores in the cluster. Enter a site identifier and datastore identifier to get specific datastore info. + +## SYNTAX + +### AllInfo (Default) +``` +Get-ZADatastore -siteIdentifier [] +``` + +### datastore +``` +Get-ZADatastore -siteIdentifier -datastoreIdentifier [] +``` + +### cluster +``` +Get-ZADatastore -siteIdentifier -clusterIdentifier [] +``` + +## DESCRIPTION + +Get a list of datastore/s, filtered by site. Enter a site identifier only to get the list of all datastores. Enter a site identifier and cluster identifier to get a list of datastores in the cluster. Enter a site identifier and datastore identifier to get specific datastore info. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZADatastore -siteIdentifier "7890-1234-5678" +``` + +Returns all datastore clusters and datastores associated with site identifier "7890-1234-5678" + +### Example 2 +```powershell +PS C:\> Get-ZADatastore -siteIdentifier "7890-1234-5678" -clusterIdentifier "3456-7890-1234" +``` + +Returns datastore cluster information with identifier "3456-7890-1234" associated with site identifier "7890-1234-5678" + +### Example 3 +```powershell +PS C:\> Get-ZADatastore -siteIdentifier "7890-1234-5678" -datastoreIdentifier "5678-9012-3456" +``` + +Returns all datastore information with identifier "5678-9012-3456" associated with site identifier "7890-1234-5678" + +## PARAMETERS + +### -clusterIdentifier +The datastore cluster identifier. +Gets a list of datastores in the cluster. + +```yaml +Type: String +Parameter Sets: cluster +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -datastoreIdentifier +The datastore identifer. +Gets the datastore info. + +```yaml +Type: String +Parameter Sets: datastore +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -siteIdentifier +The site identifier. +The site identifier is mandatory. +Omit the datastore and datastore cluster identifiers to view site level storage information. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +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 Analytics REST API Endpoint for Datastores](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_datastores) diff --git a/docs/Get-ZAEvent.md b/docs/Get-ZAEvent.md new file mode 100644 index 0000000..eb6844a --- /dev/null +++ b/docs/Get-ZAEvent.md @@ -0,0 +1,140 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAEvent.md +schema: 2.0.0 +--- + +# Get-ZAEvent + +## SYNOPSIS + +Retrieve details of all existing events. + +## SYNTAX + +``` +Get-ZAEvent [[-zOrgIdentifier] ] [[-category] ] [[-limitTo] ] [[-startDate] ] + [[-endDate] ] [] +``` + +## DESCRIPTION + +Retrieve details of all existing events. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAEvent +``` + +Retrieve details of all existing events. + +### Example 2 +```powershell +PS C:\> Get-ZAEvent -zOrgIdentifier "1234-5678-9012" +``` + +Retrieve details of all existing events for zOrg with Identifier "1234-5678-9012" + +### Example 3 +```powershell +PS C:\> Get-ZAEvent -category events -startDate "2019-03-01" -endDate "2019-04-01" -limitTo 400 +``` + +Retrieve details of all events between March 1st and April 1st and limit results to 400. + +## PARAMETERS + +### -category +The event category (events/alertsHistory). +Default displays the list of all. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -endDate +The latest timestamp of an event to return, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +Default is the present time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -limitTo +The maximum number of events to return. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The earliest timestamp of an event to return, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +Default is one year ago. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the user's events. +If the ZORG identifier is omitted, events is retrieved. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Events](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_events) diff --git a/docs/Get-ZAJournalAverageHistory.md b/docs/Get-ZAJournalAverageHistory.md new file mode 100644 index 0000000..ee375b9 --- /dev/null +++ b/docs/Get-ZAJournalAverageHistory.md @@ -0,0 +1,123 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalAverageHistory.md +schema: 2.0.0 +--- + +# Get-ZAJournalAverageHistory + +## SYNOPSIS + +Retrieves the list of historical average journal history values for a specific VPG, filtered by start date, end date, and optional interval. The interval defines the journal history samples interval. + +## SYNTAX + +``` +Get-ZAJournalAverageHistory [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [[-interval] ] [] +``` + +## DESCRIPTION + +Retrieves the list of historical average journal history values for a specific VPG, filtered by start date, end date, and optional interval. The interval defines the journal history samples interval. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalAverageHistory -vpgIdentifier "9876-5432-1098" +``` + +Returns Journal Average History information for VPG with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalAverageHistory -vpgIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal Average History for VPG with identifier "9876-5432-1098" between the dates specified. + +### Example 3 +```powershell +PS C:\> Get-ZAJournalAverageHistory -vpgIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" -interval 7200 +``` + +Returns Journal Average History for VPG with identifier "9876-5432-1098" between the dates specified with a 2 hour interval. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per hour, for up to 15 days' time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Average History](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_journal_history_average) diff --git a/docs/Get-ZAJournalAverageSize.md b/docs/Get-ZAJournalAverageSize.md new file mode 100644 index 0000000..d7d4287 --- /dev/null +++ b/docs/Get-ZAJournalAverageSize.md @@ -0,0 +1,123 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalAverageSize.md +schema: 2.0.0 +--- + +# Get-ZAJournalAverageSize + +## SYNOPSIS + +Retrieves the list of historical average journal storage values for a specific VPG, filtered by start date, end date, and optional interval. The interval defines the journal storage samples interval. + +## SYNTAX + +``` +Get-ZAJournalAverageSize [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [[-interval] ] [] +``` + +## DESCRIPTION + +Retrieves the list of historical average journal storage values for a specific VPG, filtered by start date, end date, and optional interval. The interval defines the journal storage samples interval. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalAverageSize -vpgIdentifier "9876-5432-1098" +``` + +Returns Journal Average Size information for VPG with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalAverageSize -vpgIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal Average Size for VPG with identifier "9876-5432-1098" between the dates specified. + +### Example 3 +```powershell +PS C:\> Get-ZAJournalAverageSize -vpgIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" -interval 7200 +``` + +Returns Journal Average Size for VPG with identifier "9876-5432-1098" between the dates specified with a 2 hour interval. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per hour, for up to 15 days' time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Average Size](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_journal_size_average) diff --git a/docs/Get-ZAJournalBreach.md b/docs/Get-ZAJournalBreach.md new file mode 100644 index 0000000..fb8c6ed --- /dev/null +++ b/docs/Get-ZAJournalBreach.md @@ -0,0 +1,101 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalBreach.md +schema: 2.0.0 +--- + +# Get-ZAJournalBreach + +## SYNOPSIS + +Retrieves the journal history breaches over the selected timeframe. + +## SYNTAX + +``` +Get-ZAJournalBreach [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION + +Retrieves the journal history breaches over the selected timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalBreach -vpgIdentifier "9876-5432-1098" +``` + +Returns Journal Breach information for VPG with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalBreach -vpgIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal Breach information for VPG with identifier "9876-5432-1098" between the dates specified. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Breach](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_journal_breach) diff --git a/docs/Get-ZAJournalHistoryStat.md b/docs/Get-ZAJournalHistoryStat.md new file mode 100644 index 0000000..679acaf --- /dev/null +++ b/docs/Get-ZAJournalHistoryStat.md @@ -0,0 +1,101 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalHistoryStat.md +schema: 2.0.0 +--- + +# Get-ZAJournalHistoryStat + +## SYNOPSIS + +Retrieves Journal history min, max and avg Statistics over the selected timeframe. + +## SYNTAX + +``` +Get-ZAJournalHistoryStat [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION + +Retrieves Journal history min, max and avg Statistics over the selected timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalHistoryStat -vpgIdentifier "9876-5432-1098" +``` + +Returns Journal History Stats for VPG with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalHistoryStat -vpgIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal History Stats for VPG with identifier "9876-5432-1098" between the dates specified. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal History Stats](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_stats_journal_history) diff --git a/docs/Get-ZAJournalSiteAverageHistory.md b/docs/Get-ZAJournalSiteAverageHistory.md new file mode 100644 index 0000000..38fc79f --- /dev/null +++ b/docs/Get-ZAJournalSiteAverageHistory.md @@ -0,0 +1,123 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalSiteAverageHistory.md +schema: 2.0.0 +--- + +# Get-ZAJournalSiteAverageHistory + +## SYNOPSIS + +Get list of samples of average Journal History values for all VPGs replicating to a specified recovery site, filtered by start date, end date, and optional interval. The interval defines the Journal History samples interval. + +## SYNTAX + +``` +Get-ZAJournalSiteAverageHistory [-recoverySiteIdentifier] [[-startDate] ] + [[-endDate] ] [[-interval] ] [] +``` + +## DESCRIPTION + +Get list of samples of average Journal History values for all VPGs replicating to a specified recovery site, filtered by start date, end date, and optional interval. The interval defines the Journal History samples interval. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalSiteAverageHistory -recoverySiteIdentifier "9876-5432-1098" +``` + +Returns Journal Average History information for the recovery site with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalSiteAverageHistory -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal Average History information for the recovery site with identifier "9876-5432-1098" between the dates specified. + +### Example 3 +```powershell +PS C:\> Get-ZAJournalSiteAverageHistory -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" -interval 7200 +``` + +Returns Journal Average History information for the recovery site with identifier "9876-5432-1098" between the dates specified with a 2 hour interval. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per hour, for up to 15 days' time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoverySiteIdentifier +The identifier of the recovery site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Average Site History](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_site_journal_history_average) diff --git a/docs/Get-ZAJournalSiteAverageSize.md b/docs/Get-ZAJournalSiteAverageSize.md new file mode 100644 index 0000000..65b78a6 --- /dev/null +++ b/docs/Get-ZAJournalSiteAverageSize.md @@ -0,0 +1,123 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalSiteAverageSize.md +schema: 2.0.0 +--- + +# Get-ZAJournalSiteAverageSize + +## SYNOPSIS + +Get list of samples of total Journal Size of all VPGs replicating to a specified recovery site, filtered by start date, end date, and optional interval. The interval defines the Journal Size samples interval. + +## SYNTAX + +``` +Get-ZAJournalSiteAverageSize [-recoverySiteIdentifier] [[-startDate] ] [[-endDate] ] + [[-interval] ] [] +``` + +## DESCRIPTION + +Get list of samples of total Journal Size of all VPGs replicating to a specified recovery site, filtered by start date, end date, and optional interval. The interval defines the Journal Size samples interval. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalSiteAverageSize -recoverySiteIdentifier "9876-5432-1098" +``` + +Returns Journal Average Size information for the recovery site with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalSiteAverageSize -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal Average Size information for the recovery site with identifier "9876-5432-1098" between the dates specified. + +### Example 3 +```powershell +PS C:\> Get-ZAJournalSiteAverageSize -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" -interval 7200 +``` + +Returns Journal Average Size information for the recovery site with identifier "9876-5432-1098" between the dates specified with a 2 hour interval. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per hour, for up to 15 days' time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoverySiteIdentifier +The identifier of the recovery Site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Average Site Size](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_site_journal_size_average) diff --git a/docs/Get-ZAJournalSiteHistoryStat.md b/docs/Get-ZAJournalSiteHistoryStat.md new file mode 100644 index 0000000..b2573fe --- /dev/null +++ b/docs/Get-ZAJournalSiteHistoryStat.md @@ -0,0 +1,123 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalSiteHistoryStat.md +schema: 2.0.0 +--- + +# Get-ZAJournalSiteHistoryStat + +## SYNOPSIS + +Get Max, Avg. and Min Journal History statistics for all VPGs replicating to a specified recovery site, filtered by start date, end date, and optional interval. The interval defines the journal history samples interval. + +## SYNTAX + +``` +Get-ZAJournalSiteHistoryStat [-recoverySiteIdentifier] [[-startDate] ] [[-endDate] ] + [[-interval] ] [] +``` + +## DESCRIPTION + +Get Max, Avg. and Min Journal History statistics for all VPGs replicating to a specified recovery site, filtered by start date, end date, and optional interval. The interval defines the journal history samples interval. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalSiteHistoryStat -recoverySiteIdentifier "9876-5432-1098" +``` + +Returns Journal Average History information for the recovery site with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalSiteHistoryStat -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal Average History information for the recovery site with identifier "9876-5432-1098" between the dates specified. + +### Example 3 +```powershell +PS C:\> Get-ZAJournalSiteHistoryStat -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" -interval 7200 +``` + +Returns Journal Average History information for the recovery site with identifier "9876-5432-1098" between the dates specified with a 2 hour interval. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per hour, for up to 15 days' time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoverySiteIdentifier +The identifier of the recovery site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Site History Stats](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_site_journal_history_stats) diff --git a/docs/Get-ZAJournalSiteHistorySummary.md b/docs/Get-ZAJournalSiteHistorySummary.md new file mode 100644 index 0000000..9f275d5 --- /dev/null +++ b/docs/Get-ZAJournalSiteHistorySummary.md @@ -0,0 +1,123 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalSiteHistorySummary.md +schema: 2.0.0 +--- + +# Get-ZAJournalSiteHistorySummary + +## SYNOPSIS + +Get a Journal History executive summary for all VPGs replicating to a specified recovery site. + +## SYNTAX + +``` +Get-ZAJournalSiteHistorySummary [-recoverySiteIdentifier] [[-startDate] ] + [[-endDate] ] [[-interval] ] [] +``` + +## DESCRIPTION + +Get a Journal History executive summary for all VPGs replicating to a specified recovery site. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalSiteHistorySummary -recoverySiteIdentifier "9876-5432-1098" +``` + +Returns Journal History Executive Summary information for the recovery site with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalSiteHistorySummary -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal History Executive Summary information for the recovery site with identifier "9876-5432-1098" between the dates specified. + +### Example 3 +```powershell +PS C:\> Get-ZAJournalSiteHistorySummary -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" -interval 7200 +``` + +Returns Journal History Executive Summary information for the recovery site with identifier "9876-5432-1098" between the dates specified with a 2 hour interval. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per hour, for up to 15 days' time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoverySiteIdentifier +The identifier of the recovery site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Site History Summary](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_site_journal_history_summary) diff --git a/docs/Get-ZAJournalSiteSizeStat.md b/docs/Get-ZAJournalSiteSizeStat.md new file mode 100644 index 0000000..4f3244c --- /dev/null +++ b/docs/Get-ZAJournalSiteSizeStat.md @@ -0,0 +1,123 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalSiteSizeStat.md +schema: 2.0.0 +--- + +# Get-ZAJournalSiteSizeStat + +## SYNOPSIS + +Get Max, Avg. and Min of total Journal Size statistics for all VPGs replicating to a specified recovery site, filtered by start date, end date, and optional interval. The interval defines the journal history samples interval. + +## SYNTAX + +``` +Get-ZAJournalSiteSizeStat [-recoverySiteIdentifier] [[-startDate] ] [[-endDate] ] + [[-interval] ] [] +``` + +## DESCRIPTION + +Get Max, Avg. and Min of total Journal Size statistics for all VPGs replicating to a specified recovery site, filtered by start date, end date, and optional interval. The interval defines the journal history samples interval. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalSiteSizeStat -recoverySiteIdentifier "9876-5432-1098" +``` + +Returns Journal Size Statistics information for the recovery site with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalSiteSizeStat -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal Size Statistics information for the recovery site with identifier "9876-5432-1098" between the dates specified. + +### Example 3 +```powershell +PS C:\> Get-ZAJournalSiteSizeStat -recoverySiteIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" -interval 7200 +``` + +Returns Journal Size Statistics information for the recovery site with identifier "9876-5432-1098" between the dates specified with a 2 hour interval. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per hour, for up to 15 days' time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoverySiteIdentifier +The identifier of the recovery site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Site size Stats](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_site_journal_size_stats) diff --git a/docs/Get-ZAJournalStatusProportion.md b/docs/Get-ZAJournalStatusProportion.md new file mode 100644 index 0000000..479cf9a --- /dev/null +++ b/docs/Get-ZAJournalStatusProportion.md @@ -0,0 +1,101 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalStatusProportion.md +schema: 2.0.0 +--- + +# Get-ZAJournalStatusProportion + +## SYNOPSIS + +Retrieves journal history SLA status distribution over selected timeframe. + +## SYNTAX + +``` +Get-ZAJournalStatusProportion [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION + +Retrieves journal history SLA status distribution over selected timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalStatusProportion -vpgIdentifier "9876-5432-1098" +``` + +Returns Journal history SLA status distribution for VPG with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalStatusProportion -vpgIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journalhistory SLA status distribution for VPG with identifier "9876-5432-1098" between the dates specified. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Statuses Proportions](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_journal_statuses_proportions) diff --git a/docs/Get-ZAJournalStorageStat.md b/docs/Get-ZAJournalStorageStat.md new file mode 100644 index 0000000..5467598 --- /dev/null +++ b/docs/Get-ZAJournalStorageStat.md @@ -0,0 +1,101 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalStorageStat.md +schema: 2.0.0 +--- + +# Get-ZAJournalStorageStat + +## SYNOPSIS + +Retrieves Journal Storage minimum, maximum and average. Statistics over the selected timeframe. + +## SYNTAX + +``` +Get-ZAJournalStorageStat [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION + +Retrieves Journal Storage minimum, maximum and average. Statistics over the selected timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalStorageStat -vpgIdentifier "9876-5432-1098" +``` + +Returns Journal Storage Stats for VPG with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalStorageStat -vpgIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal Storage Stats for VPG with identifier "9876-5432-1098" between the dates specified. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Storage Stats](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_stats_journal_storage) diff --git a/docs/Get-ZAJournalSummary.md b/docs/Get-ZAJournalSummary.md new file mode 100644 index 0000000..0a7df27 --- /dev/null +++ b/docs/Get-ZAJournalSummary.md @@ -0,0 +1,101 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAJournalSummary.md +schema: 2.0.0 +--- + +# Get-ZAJournalSummary + +## SYNOPSIS + +Retrieves journal historical statistics for a given VPG. + +## SYNTAX + +``` +Get-ZAJournalSummary [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION + +Retrieves journal historical statistics for a given VPG. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAJournalSummary -vpgIdentifier "9876-5432-1098" +``` + +Returns Journal Summary information for VPG with identifier "9876-5432-1098" + +### Example 2 +```powershell +PS C:\> Get-ZAJournalSummary -vpgIdentifier "9876-5432-1098" -startDate "2019-06-01" -endDate "2019-06-08" +``` + +Returns Journal Summary information for VPG with identifier "9876-5432-1098" between the dates specified. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Journal Summary](https://docs.api.zerto.com/#/Journal_Reports/get_v2_reports_journal_summary) diff --git a/docs/Get-ZALicense.md b/docs/Get-ZALicense.md new file mode 100644 index 0000000..5e8c16b --- /dev/null +++ b/docs/Get-ZALicense.md @@ -0,0 +1,45 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZALicense.md +schema: 2.0.0 +--- + +# Get-ZALicense + +## SYNOPSIS + +Retrieve a list of all licenses. + +## SYNTAX + +``` +Get-ZALicense [] +``` + +## DESCRIPTION +Retrieve a list of all licenses. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZALicense +``` + +Returns all licenses and associated information + +## PARAMETERS + +### 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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API License End Point Documentation](https://docs.api.zerto.com/#/Licenses/get_v2_licenses) diff --git a/docs/Get-ZAMonitoring.md b/docs/Get-ZAMonitoring.md new file mode 100644 index 0000000..8e7b71c --- /dev/null +++ b/docs/Get-ZAMonitoring.md @@ -0,0 +1,69 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAMonitoring.md +schema: 2.0.0 +--- + +# Get-ZAMonitoring + +## SYNOPSIS + +Retrieve statistics related to all the user's sites - belonging to a single account. + +## SYNTAX + +``` +Get-ZAMonitoring [[-zOrgIdentifier] ] [] +``` + +## DESCRIPTION + +Retrieve statistics related to all the user's sites - belonging to a single account. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAMonitoring +``` + +Retrieve statistics related to all the user's sites - belonging to a single account. + +### Example 1 +```powershell +PS C:\> Get-ZAMonitoring -zOrgIdentifier "1234-5678-9012" +``` + +Retrieve statistics related to the zOrgIdentifier provided + +## PARAMETERS + +### -zOrgIdentifier +The ZORG identifier by which to filter the user's statistics for a single account. +If the ZORG identifier is omitted, statistics related to all sites, for a single account, is retrieved. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Monitoring](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_) diff --git a/docs/Get-ZANetworkSiteAverageIOPS.md b/docs/Get-ZANetworkSiteAverageIOPS.md new file mode 100644 index 0000000..c341554 --- /dev/null +++ b/docs/Get-ZANetworkSiteAverageIOPS.md @@ -0,0 +1,183 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZANetworkSiteAverageIOPS.md +schema: 2.0.0 +--- + +# Get-ZANetworkSiteAverageIOPS + +## SYNOPSIS + +Get average and maximum IOPS performance for sites, filtered by start date and end date, and optional intervals. + +## SYNTAX + +### ProtectedSite (Default) +``` +Get-ZANetworkSiteAverageIOPS -protectedSiteIdentifier [-recoverySiteIdentifier ] + [-startDate ] [-endDate ] [-zOrgIdentifier ] [-interval ] [] +``` + +### RecoverySite +``` +Get-ZANetworkSiteAverageIOPS [-protectedSiteIdentifier ] -recoverySiteIdentifier + [-startDate ] [-endDate ] [-zOrgIdentifier ] [-interval ] [] +``` + +## DESCRIPTION + +Get average and maximum IOPS performance for sites, filtered by start date and end date, and optional intervals. +The following options are available: + +* To view average and maximum IOPS performance of all outgoing traffic from a protected site to all its replicating sites, specify only the protected site identifier. +* To view average and maximum IOPS performance between two sites, specify both the protected site identifier and the recovery site identifier. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZANetworkSiteAverageIOPS -protectedSiteIdentifier "7890-1234-5678" +``` + +Returns outgoing networks IOPS average from site with identifier "7890-1234-5678" + +### Example 2 +```powershell +PS C:\> Get-ZANetworkSiteAverageIOPS -protectedSiteIdentifier "7890-1234-5678" -recoverySiteIdentifier "9876-5432-1098" +``` + +Returns network IOPS average between sites with identifiers "7890-1234-5678" and "9876-5432-1098" + +## PARAMETERS + +### -endDate +End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the end date is omitted, the default end date is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per hour, for up to 15 days' time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -protectedSiteIdentifier +Protected site identifier. +A site identification is required for at least one of the sites. + +```yaml +Type: String +Parameter Sets: ProtectedSite +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +```yaml +Type: String +Parameter Sets: RecoverySite +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoverySiteIdentifier +Recovery site identifier. +If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites. + +```yaml +Type: String +Parameter Sets: ProtectedSite +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +```yaml +Type: String +Parameter Sets: RecoverySite +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the start date is omitted, the default start date is 7 days before the end date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the executive summary. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Network Site Average IOPS](https://docs.api.zerto.com/#/Network_Reports/get_v2_reports_sites_network_iops_average) diff --git a/docs/Get-ZANetworkSiteAveragePerformance.md b/docs/Get-ZANetworkSiteAveragePerformance.md new file mode 100644 index 0000000..effcce6 --- /dev/null +++ b/docs/Get-ZANetworkSiteAveragePerformance.md @@ -0,0 +1,183 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZANetworkSiteAveragePerformance.md +schema: 2.0.0 +--- + +# Get-ZANetworkSiteAveragePerformance + +## SYNOPSIS + +Get list of samples of average and maximum network performance metrics (throughput and WAN traffic) for sites, filtered by start date and end date, and optional intervals. + +## SYNTAX + +### ProtectedSite (Default) +``` +Get-ZANetworkSiteAveragePerformance -protectedSiteIdentifier [-recoverySiteIdentifier ] + [-startDate ] [-endDate ] [-zOrgIdentifier ] [-interval ] [] +``` + +### RecoverySite +``` +Get-ZANetworkSiteAveragePerformance [-protectedSiteIdentifier ] -recoverySiteIdentifier + [-startDate ] [-endDate ] [-zOrgIdentifier ] [-interval ] [] +``` + +## DESCRIPTION + +Get list of samples of average and maximum network performance metrics (throughput and WAN traffic) for sites, filtered by start date and end date, and optional intervals. +The following options are available: + +* To view average and maximum network performance of throughput vs. WAN traffic of all outgoing traffic from a protected site to all its replicating sites, specify only the protected site identifier. +* To view average and maximum network performance of throughput and WAN traffic between two sites, specify both the protected site identifier and the recovery site identifier. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZANetworkSiteAveragePerformance -protectedSiteIdentifier "7890-1234-5678" +``` + +Returns outgoing networks performance average from site with identifier "7890-1234-5678" + +### Example 2 +```powershell +PS C:\> Get-ZANetworkSiteAveragePerformance -protectedSiteIdentifier "7890-1234-5678" -recoverySiteIdentifier "9876-5432-1098" +``` + +Returns network performance average between sites with identifiers "7890-1234-5678" and "9876-5432-1098" + +## PARAMETERS + +### -endDate +End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the end date is omitted, the default end date is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per hour, for up to 15 days' time frame or per day, for between 15 to 30 days' time frame. Submit value in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -protectedSiteIdentifier +Protected site identifier. +A site identification is required for at least one of the sites. + +```yaml +Type: String +Parameter Sets: ProtectedSite +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +```yaml +Type: String +Parameter Sets: RecoverySite +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoverySiteIdentifier +Recovery site identifier. +If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites. + +```yaml +Type: String +Parameter Sets: ProtectedSite +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +```yaml +Type: String +Parameter Sets: RecoverySite +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the start date is omitted, the default start date is 7 days before the end date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the executive summary. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Network Site Average Performance](https://docs.api.zerto.com/#/Network_Reports/get_v2_reports_sites_network_performance_average) diff --git a/docs/Get-ZANetworkSiteStat.md b/docs/Get-ZANetworkSiteStat.md new file mode 100644 index 0000000..ba37894 --- /dev/null +++ b/docs/Get-ZANetworkSiteStat.md @@ -0,0 +1,167 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAMonitoring.md +schema: 2.0.0 +--- + +# Get-ZANetworkSiteStat + +## SYNOPSIS + +Get Max, Avg. and Min network statistics for Throughput, Wan and IOPS traffic for sites, filtered by start date and end date. + +## SYNTAX + +### ProtectedSite (Default) +``` +Get-ZANetworkSiteStat -protectedSiteIdentifier [-recoverySiteIdentifier ] + [-startDate ] [-endDate ] [-zOrgIdentifier ] [] +``` + +### RecoverySite +``` +Get-ZANetworkSiteStat [-protectedSiteIdentifier ] -recoverySiteIdentifier + [-startDate ] [-endDate ] [-zOrgIdentifier ] [] +``` + +## DESCRIPTION + +Get Max, Avg. and Min network statistics for Throughput, Wan and IOPS traffic for sites, filtered by start date and end date. The following options are available: + +* To view network stats of all outgoing traffic from a protected site to all its replicating sites, specify only the protected site identifier. +* To view network stats between two sites, specify both the protected site identifier and the recovery site identifier. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZANetworkSiteStat -protectedSiteIdentifier "7890-1234-5678" +``` + +Returns all outgoing networks stats from site with identifier "7890-1234-5678" + +### Example 2 +```powershell +PS C:\> Get-ZANetworkSiteStat -protectedSiteIdentifier "7890-1234-5678" -recoverySiteIdentifier "9876-5432-1098" +``` + +Returns all networks stats between sites with identifiers "7890-1234-5678" and "9876-5432-1098" + +## PARAMETERS + +### -endDate +End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the end date is omitted, the default end date is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -protectedSiteIdentifier +Protected site identifier. +A site identification is required for at least one of the sites. + +```yaml +Type: String +Parameter Sets: ProtectedSite +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +```yaml +Type: String +Parameter Sets: RecoverySite +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoverySiteIdentifier +Recovery site identifier. +If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites. + +```yaml +Type: String +Parameter Sets: ProtectedSite +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +```yaml +Type: String +Parameter Sets: RecoverySite +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the start date is omitted, the default start date is 7 days before the end date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the executive summary. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Network Site Summary](https://docs.api.zerto.com/#/Network_Reports/get_v2_reports_sites_network_stats) diff --git a/docs/Get-ZANetworkSiteSummary.md b/docs/Get-ZANetworkSiteSummary.md new file mode 100644 index 0000000..6840ac0 --- /dev/null +++ b/docs/Get-ZANetworkSiteSummary.md @@ -0,0 +1,167 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZANetworkSiteSummary.md +schema: 2.0.0 +--- + +# Get-ZANetworkSiteSummary + +## SYNOPSIS + +Get a network executive summary for sites, filtered by start date and end date. + +## SYNTAX + +### ProtectedSite (Default) +``` +Get-ZANetworkSiteSummary -protectedSiteIdentifier [-recoverySiteIdentifier ] + [-startDate ] [-endDate ] [-zOrgIdentifier ] [] +``` + +### RecoverySite +``` +Get-ZANetworkSiteSummary [-protectedSiteIdentifier ] -recoverySiteIdentifier + [-startDate ] [-endDate ] [-zOrgIdentifier ] [] +``` + +## DESCRIPTION + +Get a network executive summary for sites, filtered by start date and end date.The following options are available: + +* To view the network executive summary of all outgoing traffic from a protected site to all its replicating sites, specify only the protected site identifier. +* To view the network executive summary between two sites, specify both the protected site identifier and the recovery site identifier. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZANetworkSiteSummary -protectedSiteIdentifier "7890-1234-5678" +``` + +Returns outgoing networks summary from site with identifier "7890-1234-5678" + +### Example 2 +```powershell +PS C:\> Get-ZANetworkSiteSummary -protectedSiteIdentifier "7890-1234-5678" -recoverySiteIdentifier "9876-5432-1098" +``` + +Returns network summary between sites with identifiers "7890-1234-5678" and "9876-5432-1098" + +## PARAMETERS + +### -endDate +End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the end date is omitted, the default end date is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -protectedSiteIdentifier +Protected site identifier. +A site identification is required for at least one of the sites. + +```yaml +Type: String +Parameter Sets: ProtectedSite +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +```yaml +Type: String +Parameter Sets: RecoverySite +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoverySiteIdentifier +Recovery site identifier. +If the recovery site identifier is omitted, the API will show all outgoing traffic from the protected site to its replicating sites. + +```yaml +Type: String +Parameter Sets: ProtectedSite +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +```yaml +Type: String +Parameter Sets: RecoverySite +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the start date is omitted, the default start date is 7 days before the end date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the executive summary. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Network Site Summary](https://docs.api.zerto.com/#/Network_Reports/get_v2_reports_sites_network_summary) diff --git a/docs/Get-ZANetworkVpgAverageIOPS.md b/docs/Get-ZANetworkVpgAverageIOPS.md new file mode 100644 index 0000000..ad707f9 --- /dev/null +++ b/docs/Get-ZANetworkVpgAverageIOPS.md @@ -0,0 +1,109 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZANetworkVpgAverageIOPS.md +schema: 2.0.0 +--- + +# Get-ZANetworkVpgAverageIOPS + +## SYNOPSIS + +Get average and maximum IOPS performance for a specific VPG, filtered by start date and end date, and optional intervals. + +## SYNTAX + +``` +Get-ZANetworkVpgAverageIOPS [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [[-interval] ] [] +``` + +## DESCRIPTION + +Get average and maximum IOPS performance for a specific VPG, filtered by start date and end date, and optional intervals. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZANetworkVpgAverageIOPS -vpgIdentifier "3456-7890-1234" -interval 3600 +``` + +Get Network VPG Average IOPS for VPG with Identifier "3456-7890-1234" for the last 7 days at an interval of 1 hour. + +## PARAMETERS + +### -endDate +End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the end date is omitted, the default end date is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per minute - for up to 6 hours, per hour - for 6 hours to 15 days, or per day - for 15 days up to 30 days. If an interval is not specified, the default is 60 seconds. Submit value in Seconds. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the start date is omitted, the default start date is 7 days before the end date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The VPG identifier. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Network VPG Average IOPS](https://docs.api.zerto.com/#/Network_Reports/get_v2_reports_vpg_network_iops_average) diff --git a/docs/Get-ZANetworkVpgAveragePerformance.md b/docs/Get-ZANetworkVpgAveragePerformance.md new file mode 100644 index 0000000..8c66050 --- /dev/null +++ b/docs/Get-ZANetworkVpgAveragePerformance.md @@ -0,0 +1,109 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZANetworkVpgAveragePerformance.md +schema: 2.0.0 +--- + +# Get-ZANetworkVpgAveragePerformance + +## SYNOPSIS + +Get average and maximum network performance of throughput vs. WAN traffic for a specific VPG filtered by start date and end date, and optional intervals. + +## SYNTAX + +``` +Get-ZANetworkVpgAveragePerformance [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [[-interval] ] [] +``` + +## DESCRIPTION + +Get average and maximum network performance of throughput vs. WAN traffic for a specific VPG filtered by start date and end date, and optional intervals + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZANetworkVpgAveragePerformance -vpgIdentifier "3456-7890-1234" -interval 3600 +``` + +Get Network VPG Average Performance for VPG with Identifier "3456-7890-1234" for the last 7 days at an interval of 1 hour. + +## PARAMETERS + +### -endDate +End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the end date is omitted, the default end date is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. The interval can be per minute - for up to 6 hours, per hour - for 6 hours to 15 days, or per day - for 15 days up to 30 days. If an interval is not specified, the default is 60 seconds. Submit value in Seconds. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the start date is omitted, the default start date is 7 days before the end date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The VPG identifier. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Network VPG Average Performance](https://docs.api.zerto.com/#/Network_Reports/get_v2_reports_vpg_network_performance_average) diff --git a/docs/Get-ZANetworkVpgStat.md b/docs/Get-ZANetworkVpgStat.md new file mode 100644 index 0000000..2820450 --- /dev/null +++ b/docs/Get-ZANetworkVpgStat.md @@ -0,0 +1,94 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZANetworkVpgStat.md +schema: 2.0.0 +--- + +# Get-ZANetworkVpgStat + +## SYNOPSIS + +Get Max, Avg. and Min network statistics for Throughput, Wan and IOPS traffic for a given VPG, filtered by start date and end date. + +## SYNTAX + +``` +Get-ZANetworkVpgStat [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION + +Get Max, Avg. and Min network statistics for Throughput, Wan and IOPS traffic for a given VPG, filtered by start date and end date. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZANetworkVpgStat -vpgIdentifier "3456-7890-1234" +``` + +Get Network VPG Stats for VPG with Identifier "3456-7890-1234" for the last 7 days. + +## PARAMETERS + +### -endDate +End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the end date is omitted, the default end date is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the start date is omitted, the default start date is 7 days before the end date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The VPG identifier. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Network VPG Summary](https://docs.api.zerto.com/#/Network_Reports/get_v2_reports_vpg_network_summary) diff --git a/docs/Get-ZANetworkVpgSummary.md b/docs/Get-ZANetworkVpgSummary.md new file mode 100644 index 0000000..54eef27 --- /dev/null +++ b/docs/Get-ZANetworkVpgSummary.md @@ -0,0 +1,94 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZANetworkVpgSummary.md +schema: 2.0.0 +--- + +# Get-ZANetworkVpgSummary + +## SYNOPSIS + +Get a network executive summary for a given VPG, filtered by start date and end date. + +## SYNTAX + +``` +Get-ZANetworkVpgSummary [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION + +Get a network executive summary for a given VPG, filtered by start date and end date. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZANetworkVpgSummary -vpgIdentifier "3456-7890-1234" +``` + +Get Network VPG Summary for VPG with Identifier "3456-7890-1234" for the last 7 days. + +## PARAMETERS + +### -endDate +End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the end date is omitted, the default end date is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the start date is omitted, the default start date is 7 days before the end date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The VPG identifier. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Network VPG Summary](https://docs.api.zerto.com/#/Network_Reports/get_v2_reports_vpg_network_summary) diff --git a/docs/Get-ZAPlannerJournalSizeReport.md b/docs/Get-ZAPlannerJournalSizeReport.md new file mode 100644 index 0000000..8d69627 --- /dev/null +++ b/docs/Get-ZAPlannerJournalSizeReport.md @@ -0,0 +1,163 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerJournalSizeReport.md +schema: 2.0.0 +--- + +# Get-ZAPlannerJournalSizeReport + +## SYNOPSIS +Create a report request to retrieve the Journal Size for a specific VMs list, and timeframe. + +## SYNTAX + +``` +Get-ZAPlannerJournalSizeReport [-siteIdentifier] [-recoveryType] [-vmIdentifier] + [[-desiredJournalHistory] ] [[-startDate] ] [[-endDate] ] [] +``` + +## DESCRIPTION +Create a report request to retrieve the Journal Size for a specific VMs list, and timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAPlannerJournalSizeReport -siteIdentifier '1234567890-01923141' -recoveryType VMware -vmIdentifier 'vmIdentifier1', 'vmIdentifier2' +``` + +Gets a Journal report for VMs with identifiers 'vmIdentifier1' and 'vmIdentifier2' at source siteIdentifier '1234567890-01923141' where the target recovery location is VMware. The report will cover a Journal History of 24 hours. This will use all data contained in Zerto Analytics to create the Journal report. + +### Example 2 +```powershell +PS C:\> Get-ZAPlannerJournalSizeReport -siteIdentifier '1234567890-01923141' -recoveryType VMware -vmIdentifier 'vmIdentifier1', 'vmIdentifier2' -desiredJournalHistory 96 +``` + +Gets a Journal report for VMs with identifiers 'vmIdentifier1' and 'vmIdentifier2' at source siteIdentifier '1234567890-01923141' where the target recovery location is VMware. The report will cover a Journal History of 96 hours (4 days). This will use all data contained in Zerto Analytics to create the Journal report. + +### Example 3 +```powershell +PS C:\> Get-ZAPlannerJournalSizeReport -siteIdentifier '1234567890-01923141' -recoveryType VMware -vmIdentifier 'vmIdentifier1', 'vmIdentifier2' -desiredJournalHistory 96 -startDate '2020-01-01' +``` + +Gets a Journal report for VMs with identifiers 'vmIdentifier1' and 'vmIdentifier2' at source siteIdentifier '1234567890-01923141' where the target recovery location is VMware. The report will cover a Journal History of 96 hours (4 days). This will use all data starting from Jan 1st to today contained in Zerto Analytics to create the Journal report. + +### Example 4 +```powershell +PS C:\> Get-ZAPlannerJournalSizeReport -siteIdentifier '1234567890-01923141' -recoveryType VMware -vmIdentifier 'vmIdentifier1', 'vmIdentifier2' -desiredJournalHistory 96 -startDate '2020-01-01' -endDate '2020-01-30' +``` + +Gets a Journal report for VMs with identifiers 'vmIdentifier1' and 'vmIdentifier2' at source siteIdentifier '1234567890-01923141' where the target recovery location is VMware. The report will cover a Journal History of 96 hours (4 days). This will use all data starting from Jan 1st to Jan 30th contained in Zerto Analytics to create the Journal report. + +## PARAMETERS + +### -desiredJournalHistory +The desired journal history in hours. +The default is 24 hours. +Limited to a 1 hour up to 720 hours, or the equivalent of 30 days + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 24 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -endDate +The latest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 6 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoveryType +Type of target recovery site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -siteIdentifier +The site identifier(s) for which to return detailed information. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The earliest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is one year ago. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vmIdentifier +Identifiers of the VMs you want to recover at the target recovery site. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Planner Journal Size Report - Post](https://docs.api.zerto.com/#/Planner/post_v2_planner_reports_stats_journal_size) +[Zerto Planner Journal Size Report - Get](https://docs.api.zerto.com/#/Planner/get_v2_planner_reports_stats_journal_size) diff --git a/docs/Get-ZAPlannerNetworkPerformanceReport.md b/docs/Get-ZAPlannerNetworkPerformanceReport.md new file mode 100644 index 0000000..e69dbbd --- /dev/null +++ b/docs/Get-ZAPlannerNetworkPerformanceReport.md @@ -0,0 +1,158 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerNetworkPerformanceReport.md +schema: 2.0.0 +--- + +# Get-ZAPlannerNetworkPerformanceReport + +## SYNOPSIS +Create a report request to retrieve the Network Performance for a specific VMs list, and timeframe. + +## SYNTAX + +``` +Get-ZAPlannerNetworkPerformanceReport [-siteIdentifier] [-recoveryType] + [-vmIdentifier] [[-interval] ] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION +Create a report request to retrieve the Network Performance for a specific VMs list, and timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAPlannerNetworkPerformanceReport -siteIdentifier '1234567890-01923141' -recoveryType VMware -vmIdentifier 'vmIdentifier1', 'vmIdentifier2' +``` + +Gets a Network Performance report for VMs with identifiers 'vmIdentifier1' and 'vmIdentifier2' at source siteIdentifier '1234567890-01923141' where the target recovery location is VMware. This will use all data contained in Zerto Analytics to create the Journal report. + +### Example 2 +```powershell +PS C:\> Get-ZAPlannerNetworkPerformanceReport -siteIdentifier '1234567890-01923141' -recoveryType VMware -vmIdentifier 'vmIdentifier1', 'vmIdentifier2' -startDate '2020-01-01' -interval 86400 +``` + +Gets a Network Performance report for VMs with identifiers 'vmIdentifier1' and 'vmIdentifier2' at source siteIdentifier '1234567890-01923141' where the target recovery location is VMware. This will use data contained in Zerto Analytics starting Jan 1st, 2020 ending on the day the report is run to create the Journal report. Sample reporting interval will be 86400 seconds (1 day). + +### Example 3 +```powershell +PS C:\> Get-ZAPlannerNetworkPerformanceReport -siteIdentifier '1234567890-01923141' -recoveryType VMware -vmIdentifier 'vmIdentifier1', 'vmIdentifier2' -startDate '2020-01-01' -endDate '2020-01-30' -interval 86400 +``` + +Gets a Network Performance report for VMs with identifiers 'vmIdentifier1' and 'vmIdentifier2' at source siteIdentifier '1234567890-01923141' where the target recovery location is VMware. This will use data contained in Zerto Analytics starting Jan 1st, 2020 ending on Jan 30th, 2020 to create the Journal report. Sample reporting interval will be 86400 seconds (1 day). + +## PARAMETERS + +### -endDate +The latest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 6 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The desired sample interval in seconds. +The default is 3600 seconds (1 Hour). +Limited to a 60 second to 86,400 second (24 Hour) interval + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 3600 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoveryType +Type of target recovery site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -siteIdentifier +The site identifier(s) for which to return detailed information. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The earliest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is one year ago. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vmIdentifier +Identifiers of the VMs you want to recover at the target recovery site. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics Planner Network-Performance API Endpoint - POST](https://docs.api.zerto.com/#/Planner/post_v2_planner_reports_network_performance) +[Zerto Analytics Planner Network-Performance API Endpoint - GET](https://docs.api.zerto.com/#/Planner/get_v2_planner_reports_network_performance) + diff --git a/docs/Get-ZAPlannerSite.md b/docs/Get-ZAPlannerSite.md new file mode 100644 index 0000000..f977330 --- /dev/null +++ b/docs/Get-ZAPlannerSite.md @@ -0,0 +1,67 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerSite.md +schema: 2.0.0 +--- + +# Get-ZAPlannerSite + +## SYNOPSIS +Retrieve all active Planner sites for a specific account - includes ID, Name and Type or retrieves datacenter, host, and VMs for a specific site. + +## SYNTAX + +``` +Get-ZAPlannerSite [[-siteIdentifier] ] [] +``` + +## DESCRIPTION +Retrieve all active Planner sites for a specific account - includes ID, Name and Type or retrieves datacenter, host, and VMs for a specific site. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAPlannerSite +``` + +Retrieve all active Planner sites for a specific account + +### Example 2 +```powershell +PS C:\> Get-ZAPlannerSite -siteIdentifier '0123-45676-09876' +``` + +Retrieves datacenter, host, and VMs for site with Identifier '0123-45676-09876'. + +## PARAMETERS + +### -siteIdentifier +The site identifier(s) for which to return detailed information. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics Sites Planner Endpoint](https://docs.api.zerto.com/#/Planner/get_v2_planner_sites) +[Zerto Analytics Single Site Planner Endpoint](https://docs.api.zerto.com/#/Planner/get_v2_planner_sites__siteIdentifier_) diff --git a/docs/Get-ZAPlannerStatsReport.md b/docs/Get-ZAPlannerStatsReport.md new file mode 100644 index 0000000..bdecfbb --- /dev/null +++ b/docs/Get-ZAPlannerStatsReport.md @@ -0,0 +1,149 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerStatsReport.md +schema: 2.0.0 +--- + +# Get-ZAPlannerStatsReport + +## SYNOPSIS +Create a report request for the selected VMs for a specific timeframe, retrieving all stats data for ZCAs, WAN, Journal size and array of VMs avg IOPs, avg throughput and journal size. + +## SYNTAX + +``` +Get-ZAPlannerStatsReport [-siteIdentifier] [-recoveryType] [-vmIdentifier] + [[-desiredJournalHistory] ] [[-startDate] ] [[-endDate] ] [] +``` + +## DESCRIPTION +Create a report request for the selected VMs for a specific timeframe, retrieving all stats data for ZCAs, WAN, Journal size and array of VMs avg IOPs, avg throughput and journal size. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAPlannerStatsReport -siteIdentifier '0123-45676-09876' -recoveryType vcenter -vmIdentifier 'vmIdentifier01', 'vmIdentifier02' +``` + +Will get a stats report for the two VMs listed recovering to a vCenter site with a 24 hour journal + +### Example 2 +```powershell +PS C:\> Get-ZAPlannerStatsReport -siteIdentifier '0123-45676-09876' -recoveryType Azure -vmIdentifier 'vmIdentifier01', 'vmIdentifier02' -desiredJournalHistory 72 +``` + +Will get a stats report for the two VMs listed recovering to an Azure site with a 72 hour journal + +## PARAMETERS + +### -desiredJournalHistory +The desired journal history in hours. +The default is 24 hours. +Limited to a 1 hour up to 720 hours, or the equivalent of 30 days + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 24 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -endDate +The latest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 6 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoveryType +Type of target recovery site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -siteIdentifier +The site identifier(s) for which to return detailed information. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The earliest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is one year ago. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vmIdentifier +Identifiers of the VMs you want to recover at the target recovery site. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics Planner Stats API Endpoint - POST](https://docs.api.zerto.com/#/Planner/post_v2_planner_reports_stats) +[Zerto Analytics Planner Stats API Endpoint - GET](https://docs.api.zerto.com/#/Planner/get_v2_planner_reports_stats) diff --git a/docs/Get-ZAPlannerWanReport.md b/docs/Get-ZAPlannerWanReport.md new file mode 100644 index 0000000..88e0f4c --- /dev/null +++ b/docs/Get-ZAPlannerWanReport.md @@ -0,0 +1,125 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerWanReport.md +schema: 2.0.0 +--- + +# Get-ZAPlannerWanReport + +## SYNOPSIS +Create a report request to retrieve WAN for a specific VMs list, and timeframe. + +## SYNTAX + +``` +Get-ZAPlannerWanReport [-siteIdentifier] [-recoveryType] [-vmIdentifier] + [[-startDate] ] [[-endDate] ] [] +``` + +## DESCRIPTION +Create a report request to retrieve WAN for a specific VMs list, and timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAPlannerWanReport -siteIdentifier '12345-0987654-254364' -recoveryType vcenter -vmIdentifier '1234-98789-0987', '1234-98789-1252' +``` + +Get a WAN requirements report for VMs at the protected site. + +## PARAMETERS + +### -endDate +The latest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoveryType +Type of target recovery site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -siteIdentifier +The site identifier(s) for which to return detailed information. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The earliest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is one year ago. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vmIdentifier +Identifiers of the VMs you want to recover at the target recovery site. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics Planner Wan Stats API Endpoint - POST](https://docs.api.zerto.com/#/Planner/post_v2_planner_reports_stats_wan) +[Zerto Analytics Planner Wan Stats API Endpoint - GET](https://docs.api.zerto.com/#/Planner/get_v2_planner_reports_stats_wan) diff --git a/docs/Get-ZAPlannerZcasReport.md b/docs/Get-ZAPlannerZcasReport.md new file mode 100644 index 0000000..bdde4dc --- /dev/null +++ b/docs/Get-ZAPlannerZcasReport.md @@ -0,0 +1,125 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAPlannerZcasReport.md +schema: 2.0.0 +--- + +# Get-ZAPlannerZcasReport + +## SYNOPSIS +Create a report request to retrieve ZCAs for a specific VMs list, and timeframe. + +## SYNTAX + +``` +Get-ZAPlannerZcasReport [-siteIdentifier] [-recoveryType] [-vmIdentifier] + [[-startDate] ] [[-endDate] ] [] +``` + +## DESCRIPTION +Create a report request to retrieve ZCAs for a specific VMs list, and timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAPlannerZcasReport -siteIdentifier '12345-0987654-254364' -recoveryType azure -vmIdentifier '1234-98789-0987', '1234-98789-1252' +``` + +Get a report for the number of required ZCA's in Azure to protect the supplied VMs. + +## PARAMETERS + +### -endDate +The latest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -recoveryType +Type of target recovery site. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -siteIdentifier +The site identifier(s) for which to return detailed information. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The earliest timestamp of an event to return, in RFC 3339 standard. +('1970-01-01T00:00:00Z'). +The default is one year ago. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vmIdentifier +Identifiers of the VMs you want to recover at the target recovery site. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics Planner ZCA Stats API Endpoint - POST](https://docs.api.zerto.com/#/Planner/post_v2_planner_reports_stats_zcas) +[Zerto Analytics Planner ZCA Stats API Endpoint - GET](https://docs.api.zerto.com/#/Planner/get_v2_planner_reports_stats_zcas) diff --git a/docs/Get-ZAProtectedVm.md b/docs/Get-ZAProtectedVm.md new file mode 100644 index 0000000..c6726d2 --- /dev/null +++ b/docs/Get-ZAProtectedVm.md @@ -0,0 +1,120 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAProtectedVm.md +schema: 2.0.0 +--- + +# Get-ZAProtectedVm + +## SYNOPSIS +Gets information about currently protected Virtual Machines in all sites. If desired a subset of VMs can be returned by providing VM Identifiers for each virtual machine. + +## SYNTAX + +### AllVMs (Default) +``` +Get-ZAProtectedVm [-AllVms] [] +``` + +### IndividualVMs +``` +Get-ZAProtectedVm -VMIdentifier [-Volumes] [] +``` + +## DESCRIPTION +Gets information about currently protected Virtual Machines in all sites. If desired a subset of VMs can be returned by providing VM Identifiers for each virtual machine. Finally, when gathering information for individual virtual machines, the `-Volumes` parameter can be specified to return volume information for the protected VM. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAProtectedVm +``` + +Returns all protected virtual machines across all sites. + +### Example 2 +```powershell +PS C:\> Get-ZAProtectedVm -AllVMs +``` + +Returns all protected virtual machines across all sites. + +### Example 3 +```powershell +PS C:\> Get-ZAProtectedVm -VMIdentifier '09914-12345-12341235', '81238-12532-12355332' +``` + +Returns information for only the two specified virtual machines + +### Example 4 +```powershell +PS C:\> Get-ZAProtectedVm -VMIdentifier '09914-12345-12341235', '81238-12532-12355332' -Volumes +``` + +Returns volume information for the two specified virtual machines + +## PARAMETERS + +### -AllVms +Use this switch when you want a list of all protected VMs. +Please be warned this list can be quite large. + +```yaml +Type: SwitchParameter +Parameter Sets: AllVMs +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -VMIdentifier +A list of VM identifiers to query + +```yaml +Type: String[] +Parameter Sets: IndividualVMs +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Volumes +Specify this switch when you would like protected vms' volume information returned + +```yaml +Type: SwitchParameter +Parameter Sets: IndividualVMs +Aliases: + +Required: False +Position: Named +Default value: False +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics Protected VMs API Endpoint - AllVMs](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_protected_vms) +[Zerto Analytics Protected VMs API Endpoint - List of VMs](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_protected_vms__vmIdentifier_) +[Zerto Analytics Protected VMs API Endpoint - Volumes of VMs](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_protected_vms__vmIdentifier__volumes) + diff --git a/docs/Get-ZAProtectedVmReport.md b/docs/Get-ZAProtectedVmReport.md new file mode 100644 index 0000000..45fae12 --- /dev/null +++ b/docs/Get-ZAProtectedVmReport.md @@ -0,0 +1,60 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAProtectedVmReport.md +schema: 2.0.0 +--- + +# Get-ZAProtectedVmReport + +## SYNOPSIS +Creates a report of the requested protected virtual machines' volumes. + +## SYNTAX + +``` +Get-ZAProtectedVmReport -VMIdentifier [] +``` + +## DESCRIPTION +Creates a report of the requested protected virtual machines' volumes. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAProtectedVmReport -VMIdentifier '09914-12345-12341235', '81238-12532-12355332' +``` + +Generates a protected vm report for the virtual machines with the specified VMIdentifiers. + +## PARAMETERS + +### -VMIdentifier +A list of VM identifiers to include in the report. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics Protected VMs Report API Endpoint - POST](https://docs.api.zerto.com/#/Monitoring/post_v2_monitoring_protected_vms) +[Zerto Analytics Protected VMs Report API Endpoint - GET](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_protected_vms_reportId__reportId_) diff --git a/docs/Get-ZARPOAccountAverage.md b/docs/Get-ZARPOAccountAverage.md new file mode 100644 index 0000000..3d8803f --- /dev/null +++ b/docs/Get-ZARPOAccountAverage.md @@ -0,0 +1,109 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Get-ZARPOAccountAverage.md +schema: 2.0.0 +--- + +# Get-ZARPOAccountAverage + +## SYNOPSIS + +Get average RPO for all VPGs in a single account, filtered by last 30 days. + +## SYNTAX + +``` +Get-ZARPOAccountAverage [[-zOrgIdentifier] ] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION + +Get average RPO for all VPGs in a single account, filtered by last 30 days. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZARPOAccountAverage +``` + +Get average RPO for all VPGs in a single account. + +### Example 2 +```powershell +PS C:\> Get-ZARPOAccountAverage -zOrgIdentifier "1234-5678-9012" +``` + +Get average RPO for all VPGs in zOrg with identifier "1234-5678-9012". + +### Example 3 +```powershell +PS C:\> Get-ZARPOAccountAverage -startDate "2019-06-01T00:00:00Z" -endDate "2019-06-02T00:00:00Z" +``` + +Get average RPO for all VPGs in a single account for June 6th, 2019 + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the user's average RPO for a single account. +If the ZORG identifier is omitted, statistics related to all sites, for a single account, is retrieved. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Account RPO Average](https://docs.api.zerto.com/#/RPO_Reports/get_v2_reports_account_rpo_average) diff --git a/docs/Get-ZARPOAverage.md b/docs/Get-ZARPOAverage.md new file mode 100644 index 0000000..4264ab8 --- /dev/null +++ b/docs/Get-ZARPOAverage.md @@ -0,0 +1,118 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Get-ZARPOAverage.md +schema: 2.0.0 +--- + +# Get-ZARPOAverage + +## SYNOPSIS + +Retrieves list of average RPO values for a specific VPG, filtered by start date, end date, and optional interval. The interval defines the RPO samples interval. by default a 1 minutes interval. + +## SYNTAX + +``` +Get-ZARPOAverage [-vpgIdentifier] [[-startDate] ] [[-endDate] ] [[-interval] ] + [] +``` + +## DESCRIPTION + +Retrieves list of average RPO values for a specific VPG, filtered by start date, end date, and optional interval. The interval defines the RPO samples interval. by default a 1 minutes interval. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZARPOAverage -vpgIdentifier "5678-9012-3456" +``` + +Returns RPO Average over the past 7 days for VPG with Identifier "5678-9012-3456" + +### Example 2 +```powershell +PS C:\> Get-ZARPOAverage -vpgIdentifier "5678-9012-3456" -startDate "2019-06-01T12:00:00Z" -endDate "2019-06-01T14:00:00Z" -interval 60 +``` + +Returns RPO Average in one minute intervals for the time period between June 1st, 2019 at Noon to June 1st, 2019 at 14:00 for VPG with Identifier "5678-9012-3456" + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -interval +The interval selected within the duration of the report. +The interval can be 1-minute data granularity for up to 6 hours' time frame, 1-hour data granularity for 6 hours to 15 days' time frame or 1-day data granularity for 15 days up to 30 days' time frame. +Value should be submitted in Seconds + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for RPO Average](https://docs.api.zerto.com/#/RPO_Reports/get_v2_reports_rpo_average) diff --git a/docs/Get-ZARPOBreach.md b/docs/Get-ZARPOBreach.md new file mode 100644 index 0000000..5c60b30 --- /dev/null +++ b/docs/Get-ZARPOBreach.md @@ -0,0 +1,107 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZARPOBreach.md +schema: 2.0.0 +--- + +# Get-ZARPOBreach + +## SYNOPSIS + +Retrieves RPO breaches over the selected timeframe. + +## SYNTAX + +``` +Get-ZARPOBreach [-vpgIdentifier] [[-startDate] ] [[-endDate] ] [] +``` + +## DESCRIPTION + +Retrieves RPO breaches over the selected timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZARPOBreach -vpgIdentifier "3456-7890-1234" +``` + +Gets the RPO Breaches for the VPG with identifier "3456-7890-1234" for the past 7 days. + +### Example 2 +```powershell +PS C:\> Get-ZARPOBreach -vpgIdentifier "3456-7890-1234" -startDate "2019-01-01T00:00:00" +``` + +Gets the RPO Breaches for the VPG with identifier "3456-7890-1234" starting January 1st, 2019 till the date this command is run. + +### Example 3 +```powershell +PS C:\> Get-ZARPOBreach -vpgIdentifier "3456-7890-1234" -startDate "2019-01-01T00:00:00" -endDate "2019-02-01T00:00:00" +``` + +Gets the RPO Breaches for the VPG with identifier "3456-7890-1234" for the Month of January. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for RPO Breach](https://docs.api.zerto.com/#/RPO_Reports/get_v2_reports_rpo_breach) diff --git a/docs/Get-ZARPOStat.md b/docs/Get-ZARPOStat.md new file mode 100644 index 0000000..e44a232 --- /dev/null +++ b/docs/Get-ZARPOStat.md @@ -0,0 +1,107 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZARPOStat.md +schema: 2.0.0 +--- + +# Get-ZARPOStat + +## SYNOPSIS + +Retrieves Rpo min, max and avg. Stats. + +## SYNTAX + +``` +Get-ZARPOStat [-vpgIdentifier] [[-startDate] ] [[-endDate] ] [] +``` + +## DESCRIPTION + +Retrieves Rpo min, max and avg. Stats. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZARPOStat -vpgIdentifier "3456-7890-1234" +``` + +Gets the RPO Stats for the VPG with identifier "3456-7890-1234" for the past 7 days. + +### Example 2 +```powershell +PS C:\> Get-ZARPOStat -vpgIdentifier "3456-7890-1234" -startDate "2019-01-01T00:00:00" +``` + +Gets the RPO Stats for the VPG with identifier "3456-7890-1234" starting January 1st, 2019 till the date this command is run. + +### Example 3 +```powershell +PS C:\> Get-ZARPOStat -vpgIdentifier "3456-7890-1234" -startDate "2019-01-01T00:00:00" -endDate "2019-02-01T00:00:00" +``` + +Gets the RPO Stats for the VPG with identifier "3456-7890-1234" for the Month of January. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for RPO Stats](https://docs.api.zerto.com/#/RPO_Reports/get_v2_reports_stats_rpo) diff --git a/docs/Get-ZARPOStatusProportion.md b/docs/Get-ZARPOStatusProportion.md new file mode 100644 index 0000000..be274cf --- /dev/null +++ b/docs/Get-ZARPOStatusProportion.md @@ -0,0 +1,108 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZARPOStatusProportion.md +schema: 2.0.0 +--- + +# Get-ZARPOStatusProportion + +## SYNOPSIS + +Retrieves RPO SLA status distribution over the selected timeframe. + +## SYNTAX + +``` +Get-ZARPOStatusProportion [-vpgIdentifier] [[-startDate] ] [[-endDate] ] + [] +``` + +## DESCRIPTION + +Retrieves RPO SLA status distribution over the selected timeframe. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZARPOStatusProportion -vpgIdentifier "3456-7890-1234" +``` + +Gets the RPO Breaches for the VPG with identifier "3456-7890-1234" for the past 7 days. + +### Example 2 +```powershell +PS C:\> Get-ZARPOStatusProportion -vpgIdentifier "3456-7890-1234" -startDate "2019-01-01T00:00:00" +``` + +Gets the RPO Breaches for the VPG with identifier "3456-7890-1234" starting January 1st, 2019 till the date this command is run. + +### Example 3 +```powershell +PS C:\> Get-ZARPOStatusProportion -vpgIdentifier "3456-7890-1234" -startDate "2019-01-01T00:00:00" -endDate "2019-02-01T00:00:00" +``` + +Gets the RPO Breaches for the VPG with identifier "3456-7890-1234" for the Month of January. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for RPO Statuses Proportions](https://docs.api.zerto.com/#/RPO_Reports/get_v2_reports_rpo_statuses_proportions) diff --git a/docs/Get-ZARPOSummary.md b/docs/Get-ZARPOSummary.md new file mode 100644 index 0000000..40756ee --- /dev/null +++ b/docs/Get-ZARPOSummary.md @@ -0,0 +1,107 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAMonitoring.md +schema: 2.0.0 +--- + +# Get-ZARPOSummary + +## SYNOPSIS + +Retrieves RPO historical statistics for a given VPG. + +## SYNTAX + +``` +Get-ZARPOSummary [-vpgIdentifier] [[-startDate] ] [[-endDate] ] [] +``` + +## DESCRIPTION + +Retrieves RPO historical statistics for a given VPG. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZARPOSummary -vpgIdentifier "3456-7890-1234" +``` + +Gets the RPO Summary for the VPG with identifier "3456-7890-1234" for the past 7 days. + +### Example 2 +```powershell +PS C:\> Get-ZARPOSummary -vpgIdentifier "3456-7890-1234" -startDate "2019-01-01T00:00:00" +``` + +Gets the RPO Summary for the VPG with identifier "3456-7890-1234" starting January 1st, 2019 till the date this command is run. + +### Example 3 +```powershell +PS C:\> Get-ZARPOSummary -vpgIdentifier "3456-7890-1234" -startDate "2019-01-01T00:00:00" -endDate "2019-02-01T00:00:00" +``` + +Gets the RPO Summary for the VPG with identifier "3456-7890-1234" for the Month of January. + +## PARAMETERS + +### -endDate +The end date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +The default is the current time. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +The starting date of the report, in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If only the end date is added, the start date by default will be the end date minus 7 days. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The identifier of the VPG. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for RPO Summary](https://docs.api.zerto.com/#/RPO_Reports/get_v2_reports_rpo_summary) diff --git a/docs/Get-ZASite.md b/docs/Get-ZASite.md new file mode 100644 index 0000000..ccc6c4b --- /dev/null +++ b/docs/Get-ZASite.md @@ -0,0 +1,69 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZASite.md +schema: 2.0.0 +--- + +# Get-ZASite + +## SYNOPSIS + +Retrieve a list of all sites. + +## SYNTAX + +``` +Get-ZASite [[-zOrgIdentifier] ] [] +``` + +## DESCRIPTION + +Retrieve a list of all sites. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZASite +``` + +Retrieve a list of all sites. + +### Example 2 +```powershell +PS C:\> Get-ZASite -zOrgIdentifier "1234-5678-9012" +``` + +Retrieve a list of all sites managed under zOrgIdentifier "1234-5678-9012". + +## PARAMETERS + +### -zOrgIdentifier +The ZORG identifier by which to filter site list. +If the ZORG identifier is omitted, a list of all sites is retrieved. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Sites](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_sites) diff --git a/docs/Get-ZASitePair.md b/docs/Get-ZASitePair.md new file mode 100644 index 0000000..be1f53f --- /dev/null +++ b/docs/Get-ZASitePair.md @@ -0,0 +1,104 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZASitePair.md +schema: 2.0.0 +--- + +# Get-ZASitePair + +## SYNOPSIS + +Get all the sites, protected and recovery, filtered by start date and end date. + +## SYNTAX + +``` +Get-ZASitePair [[-zOrgIdentifier] ] [[-startDate] ] [[-endDate] ] [] +``` + +## DESCRIPTION + +Get all the sites, protected and recovery, filtered by start date and end date. +* When startDate is omitted, the default startDate is 7 days before the endDate. +* When endDate is ommited, the default endDate is the current date. +* When both startDate and endDate are omitted, the default date range is the last 7 days. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZASitePair +``` + +Returns all site pairings. + +### Example 1 +```powershell +PS C:\> Get-ZASitePair -zOrgIdentifier "9876-5432-1098" +``` + +Returns all site pairings belonging to zOrg with Identifier "9876-5432-1098". + +## PARAMETERS + +### -endDate +End date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the end date is omitted, the default endDate is the current date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -startDate +Start date in RFC 3339 standard ('1970-01-01T00:00:00Z'). +If the start date is omitted, the default start date is 7 days before the end date. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the site list. +If the ZORG identifier is omitted, a list of all sites is retrieved. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Site Pairs](https://docs.api.zerto.com/#/Network_Reports/get_v2_reports_sites_list) diff --git a/docs/Get-ZASiteTopology.md b/docs/Get-ZASiteTopology.md new file mode 100644 index 0000000..93cc3de --- /dev/null +++ b/docs/Get-ZASiteTopology.md @@ -0,0 +1,70 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZASiteTopology.md +schema: 2.0.0 +--- + +# Get-ZASiteTopology + +## SYNOPSIS + +Retrieves a collection of Sites topology information structures for all the available user's sites, including disabled and non-transmitting due to lack of a transmitter (older ZVR versions). + +## SYNTAX + +``` +Get-ZASiteTopology [[-zOrgIdentifier] ] [] +``` + +## DESCRIPTION + +Retrieves a collection of Sites topology information structures for all the available user's sites, including disabled and non-transmitting due to lack of a transmitter (older ZVR versions). | The following note should be taken into consideration: +The information might not be complete, since there are sites that do not transmit (disabled), yet this API concludes their presence and VPG count from the VPGs they share with transmitting sites. Such a disabled site might have relations with other disabled sites, which this API does not reveal. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZASiteTopology +``` + +Retrieves a collection of Sites topology information structures for all the available user's sites. + +### Example 2 +```powershell +PS C:\> Get-ZASiteTopology -zOrgIdentifier "1234-5678-9012" +``` + +Retrieves a collection of Sites topology information structures for all the available user's sites within zOrgIdentifier "1234-5678-9012". + +## PARAMETERS + +### -zOrgIdentifier +The ZORG identifier by which to filter sites topology list. +If the ZORG identifier is omitted, information related to all sites topology is retrieved. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Site Topology](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_sites_format_topology) diff --git a/docs/Get-ZATask.md b/docs/Get-ZATask.md new file mode 100644 index 0000000..e0bdbe7 --- /dev/null +++ b/docs/Get-ZATask.md @@ -0,0 +1,112 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZATask.md +schema: 2.0.0 +--- + +# Get-ZATask + +## SYNOPSIS + +Retrieve details of all existing tasks. + +## SYNTAX + +### zOrg (Default) +``` +Get-ZATask [-zOrgIdentifier ] [-limitTo ] [] +``` + +### taskId +``` +Get-ZATask -taskIdentifier [] +``` + +## DESCRIPTION + +Retrieve details of all existing tasks. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZATask +``` + +Retrieve details of all existing tasks. + +### Example 2 +```powershell +PS C:\> Get-ZATask -zOrgIdentifier "1234-5678-9012" +``` + +Retrieve details of all existing tasks for zOrg with Identifier "1234-5678-9012". + +### Example 1 +```powershell +PS C:\> Get-ZATask -taskIdentifier "9012-3456-7890" +``` + +Retrieve details of a specific task with identifier "9012-3456-7890". + +## PARAMETERS + +### -limitTo +The maximum number of tasks to return. + +```yaml +Type: Int32 +Parameter Sets: zOrg +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -taskIdentifier +The task Idnetifier + +```yaml +Type: String +Parameter Sets: taskId +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the task list. +If the ZORG identifier is omitted, a list of all the tasks is retrieved. + +```yaml +Type: String +Parameter Sets: zOrg +Aliases: + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for Tasks](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_tasks) diff --git a/docs/Get-ZAVolume.md b/docs/Get-ZAVolume.md new file mode 100644 index 0000000..a0030ff --- /dev/null +++ b/docs/Get-ZAVolume.md @@ -0,0 +1,137 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAVolume.md +schema: 2.0.0 +--- + +# Get-ZAVolume + +## SYNOPSIS + +Retrieves account volumes by datastore. Enter a site identifier and cluster identifier to get the list of volumes that exist in the datastore cluster. Or, enter a site identifier and datastore identifier to get the list of volumes that exist in the datastore. To retrieve all volumes for a specific VPG, enter a VPG identifier only. + +## SYNTAX + +### VpgIdentifier (Default) +``` +Get-ZAVolume -vpgIdentifier [] +``` + +### SiteAndDatastoreIdentifier +``` +Get-ZAVolume -siteIdentifier -datastoreIdentifier [] +``` + +### SiteAndClusterIdentifier +``` +Get-ZAVolume -siteIdentifier -clusterIdentifier [] +``` + +## DESCRIPTION + +Retrieves account volumes by datastore. Enter a site identifier and cluster identifier to get the list of volumes that exist in the datastore cluster. Or, enter a site identifier and datastore identifier to get the list of volumes that exist in the datastore. To retrieve all volumes for a specific VPG, enter a VPG identifier only. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAVolume -vpgIdentifier "2345-6789-0123" +``` + +Returns all volume information for all VMs in VPG with Identifier "2345-6789-0123" + +### Example 2 +```powershell +PS C:\> Get-ZAVolume -siteIdentifier "3456-7890-1234" -clusterIdentifier "0123-4567-8901" +``` + +Returns all volume information for all volumes in Site with Identifier "3456-7890-1234" on Datastore Cluster with Identifier "0123-4567-8901" + +### Example 3 +```powershell +PS C:\> Get-ZAVolume -siteIdentifier "3456-7890-1234" -datastoreIdentifier "5678-9012-3456" +``` + +Returns all volume information for all volumes in Site with Identifier "3456-7890-1234" on Datastore with Identifier "5678-9012-3456" + +## PARAMETERS + +### -clusterIdentifier +The cluster identifier. +If a cluster identifier is not entered, you must enter a datastore identifier. + +```yaml +Type: String +Parameter Sets: SiteAndClusterIdentifier +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -datastoreIdentifier +The datastore identifer. +If a datastore identifier is not entered, you must enter a cluster identifier. + +```yaml +Type: String +Parameter Sets: SiteAndDatastoreIdentifier +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -siteIdentifier +The site identifier. +The site identifier is mandatory if vpgIdentifier is not entered. + +```yaml +Type: String +Parameter Sets: SiteAndDatastoreIdentifier, SiteAndClusterIdentifier +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +The vpg identifer. + +```yaml +Type: String +Parameter Sets: VpgIdentifier +Aliases: + +Required: True +Position: Named +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 Analytics REST API Endpoint for Volumes](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_volumes) diff --git a/docs/Get-ZAVpg.md b/docs/Get-ZAVpg.md new file mode 100644 index 0000000..d8f207f --- /dev/null +++ b/docs/Get-ZAVpg.md @@ -0,0 +1,98 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAVpg.md +schema: 2.0.0 +--- + +# Get-ZAVpg + +## SYNOPSIS + +Retrieve a list of all VPGs. + +## SYNTAX + +### zOrg (Default) +``` +Get-ZAVpg [-zOrgIdentifier ] [] +``` + +### vpg +``` +Get-ZAVpg -vpgIdentifier [] +``` + +## DESCRIPTION + +Retrieve a list of all VPGs. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAVpg +``` + +Retrieve a list of all VPGs. + +### Example 2 +```powershell +PS C:\> Get-ZAVpg -zOrgIdentifier "1234-5678-9012" +``` + +Retrieve a list of all VPGs associated with zOrg "1234-5678-9012" + +### Example 3 +```powershell +PS C:\> Get-ZAVpg -vpgIdentifier "2109-8765-4321" +``` + +Retrieve information for VPG with identifier "2109-8765-4321" + +## PARAMETERS + +### -vpgIdentifier +The VPG Identifier + +```yaml +Type: String +Parameter Sets: vpg +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zOrgIdentifier +The ZORG identifier by which to filter the VPG list. +If the ZORG identifier is omitted, a list of all VPGs is retrieved. + +```yaml +Type: String +Parameter Sets: zOrg +Aliases: + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for VPGs](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_vpgs) +[Zerto Analytics REST API Endpoint for VPG Identifier](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_vpgs__vpgIdentifier_) diff --git a/docs/Get-ZAzOrg.md b/docs/Get-ZAzOrg.md new file mode 100644 index 0000000..e6eb02c --- /dev/null +++ b/docs/Get-ZAzOrg.md @@ -0,0 +1,46 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZAzOrg.md +schema: 2.0.0 +--- + +# Get-ZAzOrg + +## SYNOPSIS + +Retrieve a list of all ZORGs. + +## SYNTAX + +``` +Get-ZAzOrg [] +``` + +## DESCRIPTION + +Retrieve a list of all ZORGs. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-ZAzOrg +``` + +Retrieve a list of all ZORGs. + +## PARAMETERS + +### 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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics REST API Endpoint for ZOrgs](https://docs.api.zerto.com/#/Monitoring/get_v2_monitoring_zorgs) diff --git a/docs/Get-ZertoAlert.md b/docs/Get-ZertoAlert.md index 1dfd749..8df174b 100644 --- a/docs/Get-ZertoAlert.md +++ b/docs/Get-ZertoAlert.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoAlert.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoAlert.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoDatastore.md b/docs/Get-ZertoDatastore.md index 8db8390..d3bc777 100644 --- a/docs/Get-ZertoDatastore.md +++ b/docs/Get-ZertoDatastore.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoDatastore.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoDatastore.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoEvent.md b/docs/Get-ZertoEvent.md index 3e0c546..e42daa2 100644 --- a/docs/Get-ZertoEvent.md +++ b/docs/Get-ZertoEvent.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoEvent.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoEvent.md schema: 2.0.0 --- @@ -66,13 +66,27 @@ 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" ``` 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. + +### 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 @@ -112,6 +126,7 @@ The type of event to return. This filter behaves in the same way as the eventCat Type: String Parameter Sets: filter Aliases: +Accepted values: All, Events, Alerts Required: False Position: Named @@ -159,6 +174,7 @@ The type of entity for which you wish to return results. Possible Values are: 'V Type: String Parameter Sets: filter Aliases: +Accepted values: VPG, VRA, Unknown, Site Required: False Position: Named @@ -174,6 +190,7 @@ This filter behaves in the same way as the category filter. If both category and Type: String Parameter Sets: filter Aliases: +Accepted values: All, Events, Alerts Required: False Position: Named diff --git a/docs/Get-ZertoLicense.md b/docs/Get-ZertoLicense.md index f864948..74ca60b 100644 --- a/docs/Get-ZertoLicense.md +++ b/docs/Get-ZertoLicense.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoLicense.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoLicense.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoLocalSite.md b/docs/Get-ZertoLocalSite.md index ad0fdd9..b094547 100644 --- a/docs/Get-ZertoLocalSite.md +++ b/docs/Get-ZertoLocalSite.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoLocalSite.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoLocalSite.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoPeerSite.md b/docs/Get-ZertoPeerSite.md index 9142de4..828031b 100644 --- a/docs/Get-ZertoPeerSite.md +++ b/docs/Get-ZertoPeerSite.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoPeerSite.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoPeerSite.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoProtectedVm.md b/docs/Get-ZertoProtectedVm.md index 1d814ea..728b118 100644 --- a/docs/Get-ZertoProtectedVm.md +++ b/docs/Get-ZertoProtectedVm.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoProtectedVm.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoProtectedVm.md schema: 2.0.0 --- @@ -88,6 +88,7 @@ The priority specified for the VPG. Possible values are: 'Low', 'Medium', or 'Hi Type: String Parameter Sets: filter Aliases: +Accepted values: Low, Medium, High Required: False Position: Named diff --git a/docs/Get-ZertoRecoveryReport.md b/docs/Get-ZertoRecoveryReport.md index 0a586f7..2c6785c 100644 --- a/docs/Get-ZertoRecoveryReport.md +++ b/docs/Get-ZertoRecoveryReport.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoRecoveryReport.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoRecoveryReport.md schema: 2.0.0 --- @@ -20,7 +20,7 @@ Get-ZertoRecoveryReport [] ### filter ``` Get-ZertoRecoveryReport [-startTime ] [-endTime ] [-pageNumber ] [-pageSize ] - [-vpgIdentifier ] [-vpgName ] [-recoveryType ] [-state ] [] + [-vpgName ] [-recoveryType ] [-state ] [] ``` ## DESCRIPTION @@ -102,6 +102,7 @@ Possible values are: 'Failover', 'Failover Test', or 'Move' Type: String Parameter Sets: filter Aliases: +Accepted values: Failover, Failover Test, Move Required: False Position: Named @@ -142,22 +143,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -vpgIdentifier -The internal identifier of the VPG. -You can specify more than one VPG, separated by commas. - -```yaml -Type: String -Parameter Sets: filter -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -vpgName The name of the VPG. You can specify more than one VPG, separated by commas. diff --git a/docs/Get-ZertoResourcesReport.md b/docs/Get-ZertoResourcesReport.md index bf12822..ab0476f 100644 --- a/docs/Get-ZertoResourcesReport.md +++ b/docs/Get-ZertoResourcesReport.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoResourcesReport.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoResourcesReport.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoServiceProfile.md b/docs/Get-ZertoServiceProfile.md index 98a0c97..174ae17 100644 --- a/docs/Get-ZertoServiceProfile.md +++ b/docs/Get-ZertoServiceProfile.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoServiceProfile.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoServiceProfile.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoTask.md b/docs/Get-ZertoTask.md index 8e10bcd..a37e4f7 100644 --- a/docs/Get-ZertoTask.md +++ b/docs/Get-ZertoTask.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoTask.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoTask.md schema: 2.0.0 --- @@ -129,6 +129,7 @@ The status of the task. Possible values are: 'InProgress', 'Paused', 'Failed', ' Type: String Parameter Sets: filter Aliases: +Accepted values: InProgress, Paused, Failed, Completed, Cancelling Required: False Position: Named diff --git a/docs/Get-ZertoUnprotectedVm.md b/docs/Get-ZertoUnprotectedVm.md index ba21f4f..5da328b 100644 --- a/docs/Get-ZertoUnprotectedVm.md +++ b/docs/Get-ZertoUnprotectedVm.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoUnprotectedVm.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoUnprotectedVm.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoVirtualizationSite.md b/docs/Get-ZertoVirtualizationSite.md index 88f78cf..12c1872 100644 --- a/docs/Get-ZertoVirtualizationSite.md +++ b/docs/Get-ZertoVirtualizationSite.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVirtualizationSite.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVirtualizationSite.md schema: 2.0.0 --- @@ -18,6 +18,11 @@ Returns information about the hypervisor site where the API is run and all the s Get-ZertoVirtualizationSite [] ``` +### repositories +``` +Get-ZertoVirtualizationSite -siteIdentifier [-repositories] [] +``` + ### folders ``` Get-ZertoVirtualizationSite -siteIdentifier [-folders] [] @@ -225,6 +230,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -repositories +The identifier of the Zerto Virtual Manager site. + +```yaml +Type: SwitchParameter +Parameter Sets: repositories +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -resourcePools Return all resource pools at the selected site. @@ -245,7 +265,7 @@ The identifier of the Zerto Virtual Manager site. ```yaml Type: String -Parameter Sets: folders, devices, vms, resourcePools, networks, hosts, hostClusters, datastores, datastoreClusters, siteIdentifier +Parameter Sets: repositories, folders, devices, vms, resourcePools, networks, hosts, hostClusters, datastores, datastoreClusters, siteIdentifier Aliases: siteId Required: True @@ -271,7 +291,7 @@ 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). +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 diff --git a/docs/Get-ZertoVolume.md b/docs/Get-ZertoVolume.md index 5663b51..57c5d8e 100644 --- a/docs/Get-ZertoVolume.md +++ b/docs/Get-ZertoVolume.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVolume.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVolume.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoVpg.md b/docs/Get-ZertoVpg.md index d574889..08a0e85 100644 --- a/docs/Get-ZertoVpg.md +++ b/docs/Get-ZertoVpg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVpg.md schema: 2.0.0 --- @@ -271,6 +271,7 @@ The VPG priority. Possible values are: 'Low', 'Medium', 'High' Type: String Parameter Sets: filter Aliases: +Accepted values: Low, Medium, High Required: False Position: Named diff --git a/docs/Get-ZertoVpgSetting.md b/docs/Get-ZertoVpgSetting.md index e9a05dd..998eae0 100644 --- a/docs/Get-ZertoVpgSetting.md +++ b/docs/Get-ZertoVpgSetting.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVpgSetting.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVpgSetting.md schema: 2.0.0 --- @@ -17,6 +17,11 @@ Returns information when a VPG Settings object is created to create a new or edi Get-ZertoVpgSetting [] ``` +### ltr +``` +Get-ZertoVpgSetting -vpgSettingsIdentifier [-ltr] [] +``` + ### volumeIdentifier ``` Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier -volumeIdentifier @@ -56,7 +61,7 @@ Get-ZertoVpgSetting -vpgSettingsIdentifier [-scripting] [ [-rcovery] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-recovery] [] ``` ### priority @@ -151,10 +156,17 @@ PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -basic Returns current basic settings for vpgSettingsIdentifier "MySettingsIdentifier" +### Example 6 +```powershell +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -ltr +``` + +Returns current LTR settings for vpgSettingsIdentifier "MySettingsIdentifier" + ## PARAMETERS ### -backup -Return backup information for VPG identifier specified +Return backup information for VPG identifier specified. Please note, this parameter is ONLY available in Zerto version 7.5 and earlier. Attempting to run this switch against a Zerto Virtual Manager version 8.0 or higher result in an error. ```yaml Type: SwitchParameter @@ -199,7 +211,7 @@ Accept wildcard characters: False ``` ### -dayOfWeek -Get the day of week a backup is scheduled +Get the day of week a backup is scheduled. Please note, this parameter is ONLY available in Zerto version 7.5 and earlier. Attempting to run this switch against a Zerto Virtual Manager version 8.0 or higher result in an error. ```yaml Type: SwitchParameter @@ -228,6 +240,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -ltr +Return LTR information for the specified VPG. Please note, this parameter is ONLY available in Zerto version 8.0 and later. Attempting to run this switch against a Zerto Virtual Manager version 7.5 or lower will result in an error. + +```yaml +Type: SwitchParameter +Parameter Sets: ltr +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -networks Get VPG Network Settings @@ -288,13 +315,13 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -rcovery +### -recovery Get VPG Recovery Settings ```yaml Type: SwitchParameter Parameter Sets: recovery -Aliases: +Aliases: rcovery Required: True Position: Named @@ -304,7 +331,7 @@ Accept wildcard characters: False ``` ### -retentionPeriod -Get the retention period for a backup +Get the retention period for a backup. Please note, this parameter is ONLY available in Zerto version 7.5 and earlier. Attempting to run this switch against a Zerto Virtual Manager version 8.0 or higher result in an error. ```yaml Type: SwitchParameter @@ -319,7 +346,7 @@ Accept wildcard characters: False ``` ### -schedulerPeriod -Get the backup schedule +Get the backup schedule. Please note, this parameter is ONLY available in Zerto version 7.5 and earlier. Attempting to run this switch against a Zerto Virtual Manager version 8.0 or higher result in an error. ```yaml Type: SwitchParameter @@ -413,7 +440,7 @@ The identifier of the VPG settings object for which information is retrieved. ```yaml Type: String[] -Parameter Sets: volumeIdentifier, volumes, nicIdentifier, nics, vmIdentifier, vms, scripting, recovery, priority, networks, journal, bootGroup, basic, schedulerPeriod, retentionPeriod, dayOfWeek, backup, vpgSettingsIdentifier +Parameter Sets: ltr, volumeIdentifier, volumes, nicIdentifier, nics, vmIdentifier, vms, scripting, recovery, priority, networks, journal, bootGroup, basic, schedulerPeriod, retentionPeriod, dayOfWeek, backup, vpgSettingsIdentifier Aliases: vpgSettingsId, settingsId Required: True @@ -424,7 +451,7 @@ 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). +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 diff --git a/docs/Get-ZertoVra.md b/docs/Get-ZertoVra.md index 676e491..c2c8325 100644 --- a/docs/Get-ZertoVra.md +++ b/docs/Get-ZertoVra.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoVra.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoVra.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoZorg.md b/docs/Get-ZertoZorg.md index 5ddcd16..ebd30f9 100644 --- a/docs/Get-ZertoZorg.md +++ b/docs/Get-ZertoZorg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertoZorg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoZorg.md schema: 2.0.0 --- diff --git a/docs/Get-ZertoZsspSession.md b/docs/Get-ZertoZsspSession.md index 09ce28b..487e2eb 100644 --- a/docs/Get-ZertoZsspSession.md +++ b/docs/Get-ZertoZsspSession.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Get-ZertpZsspSession.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoZsspSession.md schema: 2.0.0 --- diff --git a/docs/Import-ZertoVmNicSetting.md b/docs/Import-ZertoVmNicSetting.md new file mode 100644 index 0000000..66876dc --- /dev/null +++ b/docs/Import-ZertoVmNicSetting.md @@ -0,0 +1,96 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Import-ZertoVmNicSetting.md +schema: 2.0.0 +--- + +# Import-ZertoVmNicSetting + +## SYNOPSIS +Using a CSV file, will import updated Live and Test network settings for protected virtual machines. + +## SYNTAX + +``` +Import-ZertoVmNicSetting [-InputFile] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Using a CSV file, will import updated Live and Test network settings for protected virtual machines. This function will read the provided CSV file and only update VMs defined in the file. + +Each entry in the CSV will be for one VM and a single NIC attached to that VM. Each entry MUST contain the following information: VPG Name, VM Name, Network Adapter Name, Mac Address Update for both Live and Test, and Network Name for both Live and Test. All other information is optional, but will be applied based on the following logic: + * If 'IsDhcp' is set to 'TRUE', the NIC setting will be set to DHCP and Primary DNS, Secondary DNS, and Search Domain settings will be applied along with the mandatory fields. + * If 'IsDhcp' is set to 'FALSE' or not set and there is an IP Address defined, the IP Address, Subnet Mask, Default Gateway, Primary DNS, Secondary DNS, and Search Domain settings will be applied along with the mandatory fields. + * if 'IsDhcp' is set to 'FALSE' or not set and there is NOT an IP Address defined, the current NIC settings will be removed and ONLY the mandatory fields will be applied. + +This logic is applied to both the Live and Test settings individually. It is recommended to use the `Export-ZertoVpgNicSetting` to dump all current settings and then modify a copy of the exported file with only the settings you wish to update. Import the copied file and if you need to revert, Import the original. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Import-ZertoVmNicSetting -InputFile 'C:\ZertoScripts\UpdatedNicInformation.csv' +``` + +Imports the data in the CSV located at 'C:\ZertoScripts\UpdatedNicInformation.csv' and updates each VM and each NIC as defined in the CSV file. + +## PARAMETERS + +### -InputFile +File to process for import + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Virtual Manager REST API VpgSettings 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.110.html%23) diff --git a/docs/Import-ZertoVpg.md b/docs/Import-ZertoVpg.md index 6d42d89..979a347 100644 --- a/docs/Import-ZertoVpg.md +++ b/docs/Import-ZertoVpg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/Import-ZertoVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Import-ZertoVpg.md schema: 2.0.0 --- diff --git a/docs/Install-ZertoVra.md b/docs/Install-ZertoVra.md index 1e2527e..b9b6136 100644 --- a/docs/Install-ZertoVra.md +++ b/docs/Install-ZertoVra.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Install-ZertoVra.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Install-ZertoVra.md schema: 2.0.0 --- @@ -12,12 +12,26 @@ Install Zerto VRA to a single host in the site with either a Static IP address, ## SYNTAX +### DhcpWithRoot +``` +Install-ZertoVra -hostName -datastoreName -networkName [-memoryInGB ] + [-groupName ] [-Dhcp] [-UseRootCredential] -HostRootPassword [-WhatIf] [-Confirm] + [] +``` + ### Dhcp ``` Install-ZertoVra -hostName -datastoreName -networkName [-memoryInGB ] [-groupName ] [-Dhcp] [-WhatIf] [-Confirm] [] ``` +### StaticIpWithRoot +``` +Install-ZertoVra -hostName -datastoreName -networkName [-memoryInGB ] + [-groupName ] -vraIpAddress -defaultGateway -subnetMask + [-UseRootCredential] -HostRootPassword [-WhatIf] [-Confirm] [] +``` + ### StaticIp ``` Install-ZertoVra -hostName -datastoreName -networkName [-memoryInGB ] @@ -44,6 +58,20 @@ PS C:\> Install-ZertoVra -hostName "Host01" -datastoreName "Datastore01" -networ Installs a VRA on the Host "Host01" using datastore "Datastore01" on network "VM Network" assigning a DHCP address. +### Example 3 +```powershell +PS C:\> Install-ZertoVra -hostName "Host01" -datastoreName "Datastore01" -networkName "VM Network" -vraIpAddress "192.168.1.50" -defaultGateway "192.168.1.254" -subnetMask "255.255.255.0" -UseRootCredential -HostRootPassword $RootPasswordAsSecureString +``` + +Installs a VRA on the Host "Host01" using datastore "Datastore01" on network "VM Network" assigning an IP address if "192.168.1.50", subnetmask of "255.255.255.0" and default gateway of "192.168.1.254" using the Root Credential install method. + +### Example 4 +```powershell +PS C:\> Install-ZertoVra -hostName "Host01" -datastoreName "Datastore01" -networkName "VM Network" -dhcp -UseRootCredential -HostRootPassword $RootPasswordAsSecureString +``` + +Installs a VRA on the Host "Host01" using datastore "Datastore01" on network "VM Network" assigning a DHCP address using the Root Credential install method. + ## PARAMETERS ### -datastoreName @@ -66,7 +94,7 @@ Default gateway to assign to the VRA ```yaml Type: String -Parameter Sets: StaticIp +Parameter Sets: StaticIpWithRoot, StaticIp Aliases: Required: True @@ -81,7 +109,7 @@ Assign a DHCP address to the VRA. ```yaml Type: SwitchParameter -Parameter Sets: Dhcp +Parameter Sets: DhcpWithRoot, Dhcp Aliases: Required: True @@ -122,6 +150,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -HostRootPassword +The password for the root user of the ESXi host where the VRA is to be installed. + +```yaml +Type: SecureString +Parameter Sets: DhcpWithRoot, StaticIpWithRoot +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -memoryInGB Initial amount of memory to assign to the VRA in GB. Default is 3, Minimum is 1, Maximum is 16 @@ -158,7 +201,22 @@ Subnetmask to be assigned to the VRA ```yaml Type: String -Parameter Sets: StaticIp +Parameter Sets: StaticIpWithRoot, StaticIp +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UseRootCredential +Use this switch to install the VRA using the root password install method. + +```yaml +Type: SwitchParameter +Parameter Sets: DhcpWithRoot, StaticIpWithRoot Aliases: Required: True @@ -173,7 +231,7 @@ Static IP address to assign to the VRA. ```yaml Type: String -Parameter Sets: StaticIp +Parameter Sets: StaticIpWithRoot, StaticIp Aliases: Required: True diff --git a/docs/Invoke-ZARestRequest.md b/docs/Invoke-ZARestRequest.md new file mode 100644 index 0000000..cad1b96 --- /dev/null +++ b/docs/Invoke-ZARestRequest.md @@ -0,0 +1,100 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZARestRequest.md +schema: 2.0.0 +--- + +# Invoke-ZARestRequest + +## SYNOPSIS +Function used to submit a REST request to the Zerto Analytics Portal. Should be used when attempting to submit a request inside a ZertoApiWrapper function or if attempting to perform an operation not currently covered in a ZertoApiWrapper function. + +## SYNTAX + +``` +Invoke-ZARestRequest [-uri] [[-method] ] [[-body] ] [] +``` + +## DESCRIPTION +Function used to submit a REST request to the Zerto Analytics Portal. Should be used when attempting to submit a request inside a ZertoApiWrapper function or if attempting to perform an operation not currently covered in a ZertoApiWrapper function. To function properly, you will have to have completed a connection to a Zerto Virtual Manager with the `Connect-ZertoAnalytics` function. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Invoke-ZertoRestRequest -uri 'apiEndpoint/subApiEndpoint' -Method GET +``` + +Submits a GET request to the connected Zerto Virtual Manager api endpoint 'apiEndpoint/subApiEndpoint'. Check the API documentation for the endpoint to ensure the URI is formatted correctly. Typically a GET request does not require a BODY parameter. + +### Example 1 +```powershell +PS C:\> Invoke-ZertoRestRequest -uri 'apiEndpoint/subApiEndpoint' -Method POST -Body $Body +``` + +Submits a PUT request to the connected Zerto Virtual Manager api endpoint 'apiEndpoint/subApiEndpoint' with a Body parameter. Check the API documentation for the endpoint to ensure the URI is formatted correctly and the format of the Body variable. The command above assumes that the $Body variable is an object that can be formatted into JSON. + +## PARAMETERS + +### -body +Body to be submitted to the REST API endpoint. +This needs to be submitted in JSON format + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -method +API method to be used. +GET, PUT, POST, or DELETE. +Refer to documentation for the API endpoint to ensure the correct method is being used. +If unspecified, defaults to GET + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: GET +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -uri +Parameter help description + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Analytics API Endpoint Documentation](https://docs.api.zerto.com/) diff --git a/docs/Invoke-ZertoEvacuateVra.md b/docs/Invoke-ZertoEvacuateVra.md new file mode 100644 index 0000000..aa0b2e9 --- /dev/null +++ b/docs/Invoke-ZertoEvacuateVra.md @@ -0,0 +1,148 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoEvacuateVra.md +schema: 2.0.0 +--- + +# Invoke-ZertoEvacuateVra + +## SYNOPSIS +This operation will move all VMs currently replicating to the selected host or VRA to different hosts based on internal Zerto algorithms. + +## SYNTAX + +### VraIdentifier (Default) +``` +Invoke-ZertoEvacuateVra -VraIdentifier [-WhatIf] [-Confirm] [] +``` + +### HostName +``` +Invoke-ZertoEvacuateVra -HostName [-WhatIf] [-Confirm] [] +``` + +### VraName +``` +Invoke-ZertoEvacuateVra -VraName [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +This operation will move all VMs currently replicating to the selected host or VRA to different hosts based on internal Zerto algorithms. + +This will return a Zerto Task Identifier so the task progress can be tracked. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Invoke-ZertoEvacuateVra -HostName 'host01' +``` + +Will move all VMs currently replicating to the selected host to different hosts. + +### Example 2 +```powershell +PS C:\> Invoke-ZertoEvacuateVra -VraName 'Z-VRA-host01' +``` + +Will move all VMs currently replicating to the selected VRA to different VRAs. + +### Example 3 +```powershell +PS C:\> Invoke-ZertoEvacuateVra -VraIdentifier '1234-1234-4312-9856' +``` + +Will move all VMs currently replicating to the selected VRA to different VRAs. + +## PARAMETERS + +### -HostName +HostName Option + +```yaml +Type: String +Parameter Sets: HostName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -VraIdentifier +VRAIdentifier Option + +```yaml +Type: String +Parameter Sets: VraIdentifier +Aliases: VraId, Identifier + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -VraName +VRA Option + +```yaml +Type: String +Parameter Sets: VraName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto REST API Evacuate VRA 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.129.html%23) + diff --git a/docs/Invoke-ZertoFailover.md b/docs/Invoke-ZertoFailover.md index 41edbae..ac68d01 100644 --- a/docs/Invoke-ZertoFailover.md +++ b/docs/Invoke-ZertoFailover.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailover.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailover.md schema: 2.0.0 --- diff --git a/docs/Invoke-ZertoFailoverCommit.md b/docs/Invoke-ZertoFailoverCommit.md index 9f1b3d1..f7876b3 100644 --- a/docs/Invoke-ZertoFailoverCommit.md +++ b/docs/Invoke-ZertoFailoverCommit.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailoverCommit.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailoverCommit.md schema: 2.0.0 --- @@ -13,7 +13,7 @@ Commit a running VPG failover ## SYNTAX ``` -Invoke-ZertoFailoverCommit [-vpgName] [-reverseProtection] [] +Invoke-ZertoFailoverCommit [-vpgName] [-reverseProtection] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -67,6 +67,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +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). diff --git a/docs/Invoke-ZertoFailoverRollback.md b/docs/Invoke-ZertoFailoverRollback.md index 51c8a09..8757c40 100644 --- a/docs/Invoke-ZertoFailoverRollback.md +++ b/docs/Invoke-ZertoFailoverRollback.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailoverRollback.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoFailoverRollback.md schema: 2.0.0 --- diff --git a/docs/Invoke-ZertoForceSync.md b/docs/Invoke-ZertoForceSync.md index 2d88313..a124bb3 100644 --- a/docs/Invoke-ZertoForceSync.md +++ b/docs/Invoke-ZertoForceSync.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoForceSync.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoForceSync.md schema: 2.0.0 --- diff --git a/docs/Invoke-ZertoMove.md b/docs/Invoke-ZertoMove.md index 6239eda..030ba21 100644 --- a/docs/Invoke-ZertoMove.md +++ b/docs/Invoke-ZertoMove.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoMove.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoMove.md schema: 2.0.0 --- @@ -12,23 +12,30 @@ Start a move of a VPG. ## SYNTAX -### main (Default) +### id (Default) ``` -Invoke-ZertoMove [-vpgName] [[-commitPolicy] ] [[-commitPolicyTimeout] ] - [-forceShutdown] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [] +Invoke-ZertoMove -vpgIdentifier [-forceShutdown] [-disableReverseProtection] [-keepSourceVms] + [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [] ``` -### disableReverseProtection +### commitName ``` -Invoke-ZertoMove [-vpgName] [[-commitPolicy] ] [[-commitPolicyTimeout] ] - [-forceShutdown] [-disableReverseProtection] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] +Invoke-ZertoMove -vpgName -commitPolicy [-commitPolicyTimeout ] [-forceShutdown] + [-disableReverseProtection] [-keepSourceVms] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [] ``` -### keepSourceVms +### name ``` -Invoke-ZertoMove [-vpgName] [[-commitPolicy] ] [[-commitPolicyTimeout] ] - [-forceShutdown] [-keepSourceVms] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [] +Invoke-ZertoMove -vpgName [-forceShutdown] [-disableReverseProtection] [-keepSourceVms] + [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [] +``` + +### commitId +``` +Invoke-ZertoMove -vpgIdentifier -commitPolicy [-commitPolicyTimeout ] [-forceShutdown] + [-disableReverseProtection] [-keepSourceVms] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -38,10 +45,24 @@ Start a move of a VPG. ### Example 1 ```powershell -PS C:\> Invoke-ZertoMove -vpgName "MyVpg" +PS C:\> Invoke-ZertoMove -vpgName 'MyVpg' ``` -Starts a move operation of VPG "MyVpg" +Specify the name of a vpg to move + +### Example 2 +```powershell +PS C:\> Invoke-ZertoMove -vpgIdentifier '2fbbf6b5-cddc-4653-b1fe-564f069eeb64' +``` + +Specify the identifier of a vpg to move + +### Example 3 +```powershell +PS C:\> Get-ZertoVpg | Invoke-ZertoMove +``` + +Utilize the pipeline to move multiple vpgs ## PARAMETERS @@ -56,11 +77,12 @@ Default is the Site Settings setting. ```yaml Type: String -Parameter Sets: (All) +Parameter Sets: commitName, commitId Aliases: +Accepted values: Rollback, Commit, None -Required: False -Position: 1 +Required: True +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -72,11 +94,11 @@ If omitted, the site settings default will be applied. ```yaml Type: Int32 -Parameter Sets: (All) +Parameter Sets: commitName, commitId Aliases: Required: False -Position: 2 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -91,7 +113,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 6 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -102,10 +124,10 @@ Do not enable reverse protection. The VPG definition is kept with the status Nee ```yaml Type: SwitchParameter -Parameter Sets: disableReverseProtection +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -121,7 +143,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 3 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -132,13 +154,28 @@ Use this switch to Prevent the protected virtual machines from being deleted in ```yaml Type: SwitchParameter -Parameter Sets: keepSourceVms +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +ID(s) of the VPG(s) you want to move. + +```yaml +Type: Guid[] +Parameter Sets: id, commitId Aliases: Required: True -Position: 5 +Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` @@ -147,11 +184,11 @@ Name(s) of the VPG(s) you want to move. ```yaml Type: String[] -Parameter Sets: (All) +Parameter Sets: commitName, name Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Invoke-ZertoMoveCommit.md b/docs/Invoke-ZertoMoveCommit.md index 08c6e92..c298a0f 100644 --- a/docs/Invoke-ZertoMoveCommit.md +++ b/docs/Invoke-ZertoMoveCommit.md @@ -12,9 +12,19 @@ Commit a VPG currently undergoing a move operation. ## SYNTAX +### Main (Default) ``` -Invoke-ZertoMoveCommit [-vpgName] [-reverseProtection] [-keepSourceVms] [-WhatIf] [-Confirm] - [] +Invoke-ZertoMoveCommit -vpgName [-WhatIf] [-Confirm] [] +``` + +### ReverseProtect +``` +Invoke-ZertoMoveCommit -vpgName [-reverseProtection] [-WhatIf] [-Confirm] [] +``` + +### KeepSource +``` +Invoke-ZertoMoveCommit -vpgName [-keepSourceVms] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -27,20 +37,33 @@ Commit a VPG currently undergoing a move operation. PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg" ``` -Commit VPG "MyVpg" after a move has been started. +Commit VPG "MyVpg" after a move operation has been completed. This commit process with use the `-KeepSourceVms` or `-ReverseProtection` selection made during the move initation. + +### Example 2 +```powershell +PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg" -keepSourceVms +``` + +Commit VPG "MyVpg" after a move operation has been completed specifying to keep the vms at the source location and NOT reverse protection. This commit process will overrule any reverse protection or keep source vms selection made during the move initiation. + +### Example 3 +```powershell +PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg" -reverseProtection +``` + +Commit VPG "MyVpg" after a move operation has been completed specifying to reverse protection of the VMs back to the source location. The VMs at the source location will be removed from inventory at the source location and the disks will be used as pre-seed volumes. This commit process will overrule any reverse protection or keep source vms selection made during the move initiation. ## PARAMETERS ### -keepSourceVms -Use this switch to keep the source VMs. -If not set, they will be destroyed. +"Use this switch to keep the source VMs at the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation." ```yaml Type: SwitchParameter -Parameter Sets: (All) +Parameter Sets: KeepSource Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False @@ -48,14 +71,14 @@ Accept wildcard characters: False ``` ### -reverseProtection -Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False +"Use this switch to reverse protect the VPG(s) to the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation." ```yaml Type: SwitchParameter -Parameter Sets: (All) +Parameter Sets: ReverseProtect Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False @@ -71,7 +94,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Invoke-ZertoMoveRollback.md b/docs/Invoke-ZertoMoveRollback.md index 4df0772..2229cc1 100644 --- a/docs/Invoke-ZertoMoveRollback.md +++ b/docs/Invoke-ZertoMoveRollback.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Invoke-ZertoMoveRollback.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoMoveRollback.md schema: 2.0.0 --- diff --git a/docs/Invoke-ZertoRestRequest.md b/docs/Invoke-ZertoRestRequest.md new file mode 100644 index 0000000..fb28ad2 --- /dev/null +++ b/docs/Invoke-ZertoRestRequest.md @@ -0,0 +1,154 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoRestRequest.md +schema: 2.0.0 +--- + +# Invoke-ZertoRestRequest + +## SYNOPSIS +Function used to submit a REST request to the Zerto Virtual Manager. Should be used when attempting to submit a request inside a ZertoApiWrapper function or if attempting to perform an operation not currently covered in a ZertoApiWrapper function. + +## SYNTAX + +``` +Invoke-ZertoRestRequest [[-method] ] [-uri] [[-body] ] [[-credential] ] + [-returnHeaders] [] +``` + +## DESCRIPTION +Function used to submit a REST request to the Zerto Virtual Manager. Should be used when attempting to submit a request inside a ZertoApiWrapper function or if attempting to perform an operation not currently covered in a ZertoApiWrapper function. To function properly, you will have to have completed a connection to a Zerto Virtual Manager with the `Connect-ZertoServer` function. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Invoke-ZertoRestRequest -uri 'apiEndpoint/subApiEndpoint' -Method POST -Body $Body +``` + +Submits a POST request to the connected Zerto Virtual Manager api endpoint 'apiEndpoint/subApiEndpoint' with a Body parameter. Check the API documentation for the endpoint to ensure the URI is formatted correctly and the format of the Body variable. The command above assumes that the $Body variable is a string properly formatted for JSON + +### Example 2 +```powershell +PS C:\> Invoke-ZertoRestRequest -uri 'apiEndpoint/subApiEndpoint' -Method POST -Body ($Body | ConvertTo-Json) +``` + +Submits a POST request to the connected Zerto Virtual Manager api endpoint 'apiEndpoint/subApiEndpoint' with a Body parameter. Check the API documentation for the endpoint to ensure the URI is formatted correctly and the format of the Body variable. The command above assumes that the $Body variable is an object that can be formatted into JSON. + +### Example 3 +```powershell +PS C:\> Invoke-ZertoRestRequest -uri 'apiEndpoint/subApiEndpoint' -Method PUT -Body $Body +``` + +Submits a PUT request to the connected Zerto Virtual Manager api endpoint 'apiEndpoint/subApiEndpoint' with a Body parameter. Check the API documentation for the endpoint to ensure the URI is formatted correctly and the format of the Body variable. The command above assumes that the $Body variable is a string properly formatted for JSON + +### Example 4 +```powershell +PS C:\> Invoke-ZertoRestRequest -uri 'apiEndpoint/subApiEndpoint' -Method DELETE +``` + +Submits a DELETE request to the connected Zerto Virtual Manager api endpoint 'apiEndpoint/subApiEndpoint'. Check the API documentation for the endpoint to ensure the URI is formatted correctly. Typically a DELETE request does not require a BODY parameter. + +### Example 5 +```powershell +PS C:\> Invoke-ZertoRestRequest -uri 'apiEndpoint/subApiEndpoint' -Method GET +``` + +Submits a GET request to the connected Zerto Virtual Manager api endpoint 'apiEndpoint/subApiEndpoint'. Check the API documentation for the endpoint to ensure the URI is formatted correctly. Typically a GET request does not require a BODY parameter. + +## PARAMETERS + +### -body +Body to be submitted to the REST API endpoint. +This needs to be submitted in JSON format + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -credential +PSCredential object. +This is ONLY used when authenticating with the ZVM. +No other endpoints require this and generally is not used. + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -method +Parameter help description + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: GET +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -returnHeaders +Use this switch if you would like the request headers returned along with the body. +Useful for troubleshooting to get HTTP error codes. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -uri +URI endpoint to be utilized. +When submitting the URI, only the endpoint needs to be submitted. +Please review the help documentation for examples. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Virtual Replication API Endpoint Documentation](https://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20(ZVM)%20-%20vSphere%20Online%20Help/content/intro/book_in_portal_-_zvr_restful_apis.htm) diff --git a/docs/New-ZertoPairingToken.md b/docs/New-ZertoPairingToken.md new file mode 100644 index 0000000..53454d2 --- /dev/null +++ b/docs/New-ZertoPairingToken.md @@ -0,0 +1,78 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/New-ZertoPairingToken.md +schema: 2.0.0 +--- + +# New-ZertoPairingToken + +## SYNOPSIS +Generates a new pairing token to be used during pairing ZVM to ZVM operations. + +## SYNTAX + +``` +New-ZertoPairingToken [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Generates a new pairing token to be used during pairing ZVM to ZVM operations. This token is valid until used or 48 hours have passed, whichever comes first. This feature is only required when pairing two Zerto sites that are both operating Zerto version 7.5 or greater. To use this feature you will need to generate a pairing token from the destination site. Once that token is generated you will use that token to pair the source site to the destination site either via the GUI or via the `Add-ZertoPeerSite` function. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> New-ZertoPairingToken +``` + +Generates an object that will contain the pairing token and expiration date and time. + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +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 Peer Sites 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.046.html%23) diff --git a/docs/New-ZertoVpg.md b/docs/New-ZertoVpg.md index cd68b3d..8c95ba6 100644 --- a/docs/New-ZertoVpg.md +++ b/docs/New-ZertoVpg.md @@ -1,17 +1,27 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/New-ZertoVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/New-ZertoVpg.md schema: 2.0.0 --- # New-ZertoVpg ## SYNOPSIS -Creates a New VPG with default settings only. Customization of VM settings can be accomplished with other module level functions. +Creates a New VPG with default settings only. Customization of VM settings can be accomplished with other module level functions. Returns a VpgSettingsIdentifier to be passed into the `Save-ZertoVpgSetting` function to create the VPG. ## SYNTAX +### recoveryHostDatastore (Default) +``` +New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours ] -protectedVm + -recoverySite -recoveryHost -datastore -recoveryFolder + [-rpoInSeconds ] [-testIntervalInMinutes ] [-serviceProfile ] + [-useWanCompression ] [-zorg ] -recoveryNetwork -testNetwork + [-journalDatastore ] [-journalHardLimitInMb ] [-journalWarningThresholdInMb ] + [-WhatIf] [-Confirm] [] +``` + ### recoveryClusterDatastoreCluster ``` New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours ] -protectedVm @@ -42,16 +52,6 @@ New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours < [-WhatIf] [-Confirm] [] ``` -### recoveryHostDatastore -``` -New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours ] -protectedVm - -recoverySite -recoveryHost -datastore -recoveryFolder - [-rpoInSeconds ] [-testIntervalInMinutes ] [-serviceProfile ] - [-useWanCompression ] [-zorg ] -recoveryNetwork -testNetwork - [-journalDatastore ] [-journalHardLimitInMb ] [-journalWarningThresholdInMb ] - [-WhatIf] [-Confirm] [] -``` - ### recoveryResourcePoolDatastoreCluster ``` New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours ] -protectedVm @@ -176,7 +176,7 @@ Name of the datastore where the VM(s), Volume(s), and Journal(s) will reside. ```yaml Type: String -Parameter Sets: recoveryClusterDatastore, recoveryHostDatastore, recoveryResourcePoolDatastore +Parameter Sets: recoveryHostDatastore, recoveryClusterDatastore, recoveryResourcePoolDatastore Aliases: Required: True @@ -312,7 +312,7 @@ Name of the host where the VM(s) will be recovered. ```yaml Type: String -Parameter Sets: recoveryHostDatastoreCluster, recoveryHostDatastore +Parameter Sets: recoveryHostDatastore, recoveryHostDatastoreCluster Aliases: Required: True @@ -537,4 +537,4 @@ Vpg Settings Identifier ## RELATED LINKS -[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) \ No newline at end of file +[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) diff --git a/docs/New-ZertoVpgSettingsIdentifier.md b/docs/New-ZertoVpgSettingsIdentifier.md index f703f1b..8128a62 100644 --- a/docs/New-ZertoVpgSettingsIdentifier.md +++ b/docs/New-ZertoVpgSettingsIdentifier.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/New-ZertoVpgSettingsIdentifier.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/New-ZertoVpgSettingsIdentifier.md schema: 2.0.0 --- diff --git a/docs/Remove-ZertoPeerSite.md b/docs/Remove-ZertoPeerSite.md index 9475bdc..a42c84b 100644 --- a/docs/Remove-ZertoPeerSite.md +++ b/docs/Remove-ZertoPeerSite.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Remove-ZertoPeerSite.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Remove-ZertoPeerSite.md schema: 2.0.0 --- @@ -160,4 +160,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## RELATED LINKS -[Zerto REST API Peer Site 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.044.html%23) \ No newline at end of file +[Zerto REST API Peer Site 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.044.html%23) diff --git a/docs/Remove-ZertoVpg.md b/docs/Remove-ZertoVpg.md index 86ef8db..877e44e 100644 --- a/docs/Remove-ZertoVpg.md +++ b/docs/Remove-ZertoVpg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Remove-ZertoVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Remove-ZertoVpg.md schema: 2.0.0 --- @@ -21,7 +21,7 @@ Remove-ZertoVpg -vpgidentifier [-keepRecoveryVolumes] [-force] [-What ### vpgName ``` -Remove-ZertoVpg [-vpgName] [-keepRecoveryVolumes] [-force] [-WhatIf] [-Confirm] [] +Remove-ZertoVpg -vpgName [-keepRecoveryVolumes] [-force] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -122,7 +122,7 @@ Parameter Sets: vpgName Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False diff --git a/docs/Remove-ZertoVpgSettingsIdentifier.md b/docs/Remove-ZertoVpgSettingsIdentifier.md new file mode 100644 index 0000000..17eb3c7 --- /dev/null +++ b/docs/Remove-ZertoVpgSettingsIdentifier.md @@ -0,0 +1,90 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Resume-ZertoVpgSettingsIdentifier.md +schema: 2.0.0 +--- + +# Remove-ZertoVpgSettingsIdentifier + +## SYNOPSIS +When a new VpgSettingsIdentifier is created, all the settings sit in memory for 30 minutes after the last change. This operation will delete the settings from memory and discard any changes. This is akin to clicking cancel on the VPG Edit Wizard screen. + +## SYNTAX + +``` +Remove-ZertoVpgSettingsIdentifier [-vpgSettingsIdentifier] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +When a new VpgSettingsIdentifier is created, all the settings sit in memory for 30 minutes after the last change. This operation will delete the settings from memory and discard any changes. This is akin to clicking cancel on the VPG Edit Wizard screen. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Remove-ZertoVpgSettingsIdentifier -vpgSettingsIdentifier "1234-7890-5678" +``` + +Removes VPG Settings Identifier "1234-7890-5678" from the Zerto Virtual Manager without applying any settings that may have changed. + +## PARAMETERS + +### -vpgSettingsIdentifier +Settings Identifier to Remove + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto Rest API VPG Settings 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.118.html%23) diff --git a/docs/Remove-ZertoVpgVm.md b/docs/Remove-ZertoVpgVm.md new file mode 100644 index 0000000..624c3b4 --- /dev/null +++ b/docs/Remove-ZertoVpgVm.md @@ -0,0 +1,121 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Resume-ZertoVpgVm.md +schema: 2.0.0 +--- + +# Remove-ZertoVpgVm + +## SYNOPSIS +Removes one or more VMs from a specified VPG. A Task Identifier is returned to track progress. + +## SYNTAX + +``` +Remove-ZertoVpgVm -VpgName -Vm [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Removes one or more VMs from a specified VPG. A Task Identifier is returned to track progress. Internal logic will remove duplicate VM names from the list of VMs provided as well as ensure membership in the VPG specified prior to attempting to remove the VM from the VPG. Finally the VPG is saved to commit the changes. ChangeImpact is set to 'High' to get the confirmation prompt. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Remove-ZertoVpgVm -VpgName 'My Vpg' -Vm 'Vm 1' +``` + +Removes 'Vm 1' from Vpg named 'My Vpg' + +### Example 2 +```powershell +PS C:\> Remove-ZertoVpgVm -VpgName 'My Vpg' -Vm 'Vm 1', 'Vm 2' +``` + +Removes 'Vm 1' and 'Vm 2' from Vpg named 'My Vpg'. + +### Example 3 +```powershell +PS C:\> Remove-ZertoVpgVm -VpgName 'My Vpg' -Vm 'Vm 1', 'Vm 2' -Confirm:$False +``` + +Removes 'Vm 1' and 'Vm 2' from Vpg named 'My Vpg' and bypasses the confirmation prompt + +## PARAMETERS + +### -Vm +Name of VM(s) to remove from the VPG + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -VpgName +Name of the VPG that contains the VM you wish to remove + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +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 +[Remove Vms from a VPG Settings Object](https://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20(ZVM)%20-%20vSphere%20Online%20Help/content/zvr_apis/vpg_management_api.htm?tocpath=ZVR%20RESTful%20APIs%7CZerto%20APIs%7C_____20#statusapis_4057192544_1361409) diff --git a/docs/Resume-ZertoVpg.md b/docs/Resume-ZertoVpg.md index 93e9f43..6e52056 100644 --- a/docs/Resume-ZertoVpg.md +++ b/docs/Resume-ZertoVpg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Resume-ZertoVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Resume-ZertoVpg.md schema: 2.0.0 --- diff --git a/docs/Save-ZertoVpgSetting.md b/docs/Save-ZertoVpgSetting.md index b0305e1..4604408 100644 --- a/docs/Save-ZertoVpgSetting.md +++ b/docs/Save-ZertoVpgSetting.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md schema: 2.0.0 --- @@ -36,10 +36,10 @@ VpgSettings Identifier to save ```yaml Type: String Parameter Sets: (All) -Aliases: vpgSettingsId +Aliases: sid, settingsIdentifier, vpgSettingsId Required: True -Position: 1 +Position: 0 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False diff --git a/docs/Set-ZertoAlert.md b/docs/Set-ZertoAlert.md index 9a7cd65..5ceb8ba 100644 --- a/docs/Set-ZertoAlert.md +++ b/docs/Set-ZertoAlert.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Set-ZertoAlert.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Set-ZertoAlert.md schema: 2.0.0 --- diff --git a/docs/Set-ZertoLicense.md b/docs/Set-ZertoLicense.md index a604a13..a353532 100644 --- a/docs/Set-ZertoLicense.md +++ b/docs/Set-ZertoLicense.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Set-ZertoLicense.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Set-ZertoLicense.md schema: 2.0.0 --- diff --git a/docs/Set-ZertoUserCredential.md b/docs/Set-ZertoUserCredential.md new file mode 100644 index 0000000..9fd7d20 --- /dev/null +++ b/docs/Set-ZertoUserCredential.md @@ -0,0 +1,97 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Set-ZertoUserCredential.md +schema: 2.0.0 +--- + +# Set-ZertoUserCredential + +## SYNOPSIS +Allows the change or update of the credentials used to allow the Zerto Virtual Manager to connect and communicate with the paired Hypervisor. + +## SYNTAX + +``` +Set-ZertoUserCredential [-UserCredential] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Allows the change or update of the credentials used to allow the Zerto Virtual Manager to connect and communicate with the paired Hypervisor. A PSCredential object is required and will be used to pass the updated credentials. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Set-ZertoUserCredential -UserCredential $UserCredential +``` + +Will update the user account used to connect the Zerto Virtual Manager to the the paired Hypervisor. + +### Example 2 +```powershell +PS C:\> Set-ZertoUserCredential -UserCredential $UserCredential -Confirm:$False +``` + +Will update the user account used to connect the Zerto Virtual Manager to the the paired Hypervisor. CAUTION: By adding the `-Confirm:$False` parameter, this will suppress the confirmation dialog and you will not be prompted if you wish to complete this action. + +## PARAMETERS + +### -UserCredential +PSCredential Object that contains the username and password for the updated credentials. + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS +[PSCredential Object Information](https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.pscredential) diff --git a/docs/Start-ZertoCloneVpg.md b/docs/Start-ZertoCloneVpg.md index 6c0cedb..9ab204d 100644 --- a/docs/Start-ZertoCloneVpg.md +++ b/docs/Start-ZertoCloneVpg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Start-ZertoCloneVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Start-ZertoCloneVpg.md schema: 2.0.0 --- diff --git a/docs/Start-ZertoFailoverTest.md b/docs/Start-ZertoFailoverTest.md index 7899454..1299291 100644 --- a/docs/Start-ZertoFailoverTest.md +++ b/docs/Start-ZertoFailoverTest.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Start-ZertoFailoverTest.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Start-ZertoFailoverTest.md schema: 2.0.0 --- diff --git a/docs/Stop-ZertoCloneVpg.md b/docs/Stop-ZertoCloneVpg.md index 5e96bd7..2c28b8d 100644 --- a/docs/Stop-ZertoCloneVpg.md +++ b/docs/Stop-ZertoCloneVpg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Stop-ZertoCloneVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Stop-ZertoCloneVpg.md schema: 2.0.0 --- diff --git a/docs/Stop-ZertoFailoverTest.md b/docs/Stop-ZertoFailoverTest.md index f4ab758..5a52590 100644 --- a/docs/Stop-ZertoFailoverTest.md +++ b/docs/Stop-ZertoFailoverTest.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Stop-ZertoFailoverTest.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Stop-ZertoFailoverTest.md schema: 2.0.0 --- diff --git a/docs/Suspend-ZertoVpg.md b/docs/Suspend-ZertoVpg.md index d1336a2..466b6d7 100644 --- a/docs/Suspend-ZertoVpg.md +++ b/docs/Suspend-ZertoVpg.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Suspend-ZertoVpg.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Suspend-ZertoVpg.md schema: 2.0.0 --- diff --git a/docs/Uninstall-ZertoVra.md b/docs/Uninstall-ZertoVra.md index b19e8f1..cae5377 100644 --- a/docs/Uninstall-ZertoVra.md +++ b/docs/Uninstall-ZertoVra.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Uninstall-ZertoVra.md +online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Uninstall-ZertoVra.md schema: 2.0.0 --- diff --git a/version.txt b/version.txt index 6e8bf73..8af85be 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.0 +1.5.3