Merge pull request #19 from wcarroll/Remove-ZertoPeerSite

Remove zerto peer site
This commit is contained in:
Wes Carroll
2019-03-26 20:57:12 -04:00
committed by GitHub
3 changed files with 516 additions and 0 deletions
@@ -0,0 +1,79 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Remove-ZertoPeerSite {
[cmdletbinding(
SupportsShouldProcess = $true,
DefaultParameterSetName = "siteIdentifier"
)]
param (
[Parameter(
HelpMessage = "Identifier of the site to be removed from the connected site",
ParameterSetName = "siteIdentifier",
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Mandatory = $true
)]
[Alias("siteId")]
[string[]]$siteIdentifier,
[Parameter(
HelpMessage = "Name of the peer site to be removed from the connected site",
ParameterSetName = "peerSiteName",
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Mandatory = $true
)]
[string[]]$peerSiteName,
[Parameter(
HelpMessage = "IP address of the peer site to be removed from the connected site",
ParameterSetName = "hostName",
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Mandatory = $true
)]
[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"
)]
[switch]$keepTargetDisks
)
begin {
$baseUri = "peersites"
$body = @{}
if ( $keepTargetDisks ) {
$body['IsKeepTargetDisks'] = $true
} else {
$body['IsKeepTargetDisks'] = $false
}
}
process {
switch ( $PSCmdlet.ParameterSetName ) {
"peerSiteName" {
$siteIdentifier = @()
$siteIdentifier = foreach ($site in $peerSiteName) {
$(Get-ZertoPeerSite -peerName $site).siteIdentifier
}
}
"hostName" {
$siteIdentifier = @()
$siteIdentifier = foreach ($name in $hostName) {
$(Get-ZertoPeerSite -hostName $name).siteIdentifier
}
}
}
foreach ($id in $siteIdentifier) {
$uri = "{0}/{1}" -f $baseUri, $id
if ($PSCmdlet.ShouldProcess("Removing siteIdentifier $id")) {
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -Method "DELETE"
}
}
}
end {
# Nothing to do
}
}
@@ -10021,6 +10021,279 @@
</maml:navigationLink>
</command:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<command:details>
<command:name>Remove-ZertoPeerSite</command:name>
<command:verb>Remove</command:verb>
<command:noun>ZertoPeerSite</command:noun>
<maml:description>
<maml:para>Unpair the current site from another site paired to it.</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>Unpair the current site from another site paired to it.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Remove-ZertoPeerSite</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="none">
<maml:name>hostName</maml:name>
<maml:Description>
<maml:para>IP address of the peer site to be removed from the connected site</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>keepTargetDisks</maml:name>
<maml:Description>
<maml:para>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</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf">
<maml:name>Confirm</maml:name>
<maml:Description>
<maml:para>Prompts you for confirmation before running the cmdlet.</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name>
<maml:Description>
<maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Remove-ZertoPeerSite</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>keepTargetDisks</maml:name>
<maml:Description>
<maml:para>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</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="none">
<maml:name>peerSiteName</maml:name>
<maml:Description>
<maml:para>Name of the peer site to be removed from the connected site</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf">
<maml:name>Confirm</maml:name>
<maml:Description>
<maml:para>Prompts you for confirmation before running the cmdlet.</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name>
<maml:Description>
<maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Remove-ZertoPeerSite</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>keepTargetDisks</maml:name>
<maml:Description>
<maml:para>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</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="siteId">
<maml:name>siteIdentifier</maml:name>
<maml:Description>
<maml:para>Identifier of the site to be removed from the connected site</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf">
<maml:name>Confirm</maml:name>
<maml:Description>
<maml:para>Prompts you for confirmation before running the cmdlet.</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name>
<maml:Description>
<maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para>
</maml:Description>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="none">
<maml:name>hostName</maml:name>
<maml:Description>
<maml:para>IP address of the peer site to be removed from the connected site</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>keepTargetDisks</maml:name>
<maml:Description>
<maml:para>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</maml:para>
</maml:Description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="none">
<maml:name>peerSiteName</maml:name>
<maml:Description>
<maml:para>Name of the peer site to be removed from the connected site</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="named" aliases="siteId">
<maml:name>siteIdentifier</maml:name>
<maml:Description>
<maml:para>Identifier of the site to be removed from the connected site</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf">
<maml:name>Confirm</maml:name>
<maml:Description>
<maml:para>Prompts you for confirmation before running the cmdlet.</maml:para>
</maml:Description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi">
<maml:name>WhatIf</maml:name>
<maml:Description>
<maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.</maml:para>
</maml:Description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes />
<command:returnValues />
<maml:alertSet>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------------------- Example 1 --------------------------</maml:title>
<dev:code>PS C:\&gt; Remove-ZertoPeerSite -siteIdentifier "MySiteIdentifier"</dev:code>
<dev:remarks>
<maml:para>Unpairs the current site for the site with siteIdentifier "MySiteIdentifier"</maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- Example 2 --------------------------</maml:title>
<dev:code>PS C:\&gt; Remove-ZertoPeerSite -peerSiteName "Recovery Site"</dev:code>
<dev:remarks>
<maml:para>Unpairs the current site for the site with site name "Recovery Site"</maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- Example 1 --------------------------</maml:title>
<dev:code>PS C:\&gt; Remove-ZertoPeerSite -hostName "192.168.1.100"</dev:code>
<dev:remarks>
<maml:para>Unpairs the current site for the site with ip address "192.168.1.100"</maml:para>
</dev:remarks>
</command:example>
</command:examples>
<command:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online Version:</maml:linkText>
<maml:uri>https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Remove-ZertoPeerSite.md</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Zerto REST API Peer Site End Point Documentation</maml:linkText>
<maml:uri>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</maml:uri>
</maml:navigationLink>
</command:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<command:details>
<command:name>Remove-ZertoVpg</command:name>
+164
View File
@@ -0,0 +1,164 @@
---
external help file: ZertoApiWrapper-help.xml
Module Name: ZertoApiWrapper
online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Remove-ZertoPeerSite.md
schema: 2.0.0
---
# Remove-ZertoPeerSite
## SYNOPSIS
Unpair the current site from another site paired to it.
## SYNTAX
### siteIdentifier (Default)
```
Remove-ZertoPeerSite -siteIdentifier <String[]> [-keepTargetDisks] [-WhatIf] [-Confirm] [<CommonParameters>]
```
### peerSiteName
```
Remove-ZertoPeerSite -peerSiteName <String[]> [-keepTargetDisks] [-WhatIf] [-Confirm] [<CommonParameters>]
```
### hostName
```
Remove-ZertoPeerSite -hostName <String[]> [-keepTargetDisks] [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Unpair the current site from another site paired to it.
## EXAMPLES
### Example 1
```powershell
PS C:\> Remove-ZertoPeerSite -siteIdentifier "MySiteIdentifier"
```
Unpairs the current site for the site with siteIdentifier "MySiteIdentifier"
### Example 2
```powershell
PS C:\> Remove-ZertoPeerSite -peerSiteName "Recovery Site"
```
Unpairs the current site for the site with site name "Recovery Site"
### Example 1
```powershell
PS C:\> Remove-ZertoPeerSite -hostName "192.168.1.100"
```
Unpairs the current site for the site with ip address "192.168.1.100"
## PARAMETERS
### -hostName
IP address of the peer site to be removed from the connected site
```yaml
Type: String[]
Parameter Sets: hostName
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```
### -keepTargetDisks
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
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -peerSiteName
Name of the peer site to be removed from the connected site
```yaml
Type: String[]
Parameter Sets: peerSiteName
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```
### -siteIdentifier
Identifier of the site to be removed from the connected site
```yaml
Type: String[]
Parameter Sets: siteIdentifier
Aliases: siteId
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
## OUTPUTS
## NOTES
## 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)