Hyper-V 13 min read

Hyper-V Replica PowerShell CMDLETS

Hyper-V Replica PowerShell CMDLETS

The following Hyper-V PowerShell cmdlets apply to Hyper-V Replica.   ****

Cmdlet

Complete-VMFailover

Description

This cmdlet completes the Failover process of the virtual machine. The virtual machine’s current recovery point is committed and all other recovery points are removed. Failover cannot be cancelled once the recovery points are removed.

Verb-Noun

Complete-VMFailover

Syntax

Complete-VMFailover [-VMName] [-ComputerName ] [-PassThru]

Example

_Complete-VMFailover -VMName C0-FIN-FS1_

Cmdlet

Get-VMNetworkAdapterFailoverConfiguration

Description

Retrieves the Failover IP settings on a virtual machine network adaptor.

Verb-Noun

Get-VMNetworkAdapterFailoverConfiguration

Syntax

Get-VMNetworkAdapterFailoverConfiguration [-VMName] [[-VMNetworkAdapterName] ] [-ComputerName ]

Example

 

cmd1

Cmdlet

Get-VMReplication

Description

Retrieve the replication relationship information of one or more virtual machines.

Verb-Noun

Get-VMReplication

Syntax

Get-VMReplication [[-VMName] ] [-ComputerName ] [-ReplicaServerName ] [-PrimaryServerName ] [-State ] [-ReplicationTag ]

Example

 

cmd2

Cmdlet

Get-VMReplicationAuthorizationEntry

Description

This cmdlet returns the details of an authorization entry as identified by the input parameter. The possible ways to get a particular authorization entry is by using AllowedPrimaryServer, or security tag.

Verb-Noun

Get-VMReplicationAuthorizationEntry

Syntax

Get-VMReplicationAuthorizationEntry [[-AllowedPrimaryServer] ] [-ComputerName ] [-ReplicaStorageLocation

Example

_Get-VMReplicationAuthorizationEntry -AllowedPrimaryServer hyp3.contoso.local -ReplicaStorageLocation e:\VirtualMachines -SecurityTag CONTOSO_

Cmdlet

Get-VMReplicationServer

Description

This cmdlet retrieves the replication settings of the Replica server. If the server has not been configured as replica server, then the command returns default object.

Verb-Noun

Get-VMReplicationServer

Syntax

Get-VMReplicationServer [[-ComputerName] ]

Example

 

cmd3

Cmdlet

Import-VMInitialReplication

Description

This cmdlet is used on the replica server to import the IR files transferred by admin using external media. The IR files are expected to be accessible using the specified path.

Verb-Noun

Import-VMInitialReplication

Syntax

Import-VMInitialReplication [-VMName] [-ComputerName ] [-Path] [-PassThru] [-AsJob]

Example

_Import-VMInitialReplication -VMName CO-LEGAL-FS11 -Path I:\Replicas\CO-LEGAL-FS11_B410F33F-55E1-44CB-A81F-6D60F408A756_

Cmdlet

Measure-VMReplication

Description

This cmdlets gets the statistics of VMReplication.

Verb-Noun

Measure-VMReplication

Syntax

Measure-VMReplication [[-VMName] ] [-ReplicaServerName ] [-ComputerName ] [-ReplicationTag ] [-State ] [-PrimaryServerName ]

Example

 

cmd4

Cmdlet

New-VMReplicationAuthorizationEntry

Description

This cmdlet creates a new authorization entry for the recovery server. The authorization entry consists of the following - AllowedPrimaryServer, ReplicaStorageLocation, KeepPrimaryStorageLocation, and SecurityTag

Verb-Noun

New-VMReplicationAuthorizationEntry

Syntax

New-VMReplicationAuthorizationEntry -KeepPrimaryStorageLocation [-AllowedPrimaryServer] [-ComputerName ]

Example

_New-VMReplicationAuthorizationEntry hyp3.contoso.local -ReplicaStorageLocation d:\ReplicaStorage DEFAULT_

Cmdlet

Remove-VMReplication

Description

This cmdlet is used to remove the replication relationship of a virtual machine. Replication relationship should be individually removed from both primary and replica virtual machines.

Verb-Noun

Remove-VMReplication

Syntax

Remove-VMReplication [-VMName] [-ComputerName ] [-PassThru]

Example

_Remove-VMReplication -VMName CO-FIN1-FS1_

Cmdlet

Remove-VMReplicationAuthorizationEntry

Description

This cmdlet enables the admin to remove an authorization entry from the Replica server, rescinding authorization of replication attempts made against the primary server associated with the entry.

Verb-Noun

Remove-VMReplicationAuthorizationEntry

Syntax

Remove-VMReplicationAuthorizationEntry [-AllowedPrimaryServer] [-ComputerName ] [-PassThru]

Example

_Remove-VMReplicationAuthorizationEntry -AllowedPrimaryServer hyp3.contoso.local_

Cmdlet

Reset-VMReplicationStatistics

Description

This cmdlet resets all the replication statistics for a specific virtual machine.  These statistics can be retrieved using the Measure-VMReplication cmdlet.

Verb-Noun

Reset-VMReplicationStatistics

Syntax

Reset-VMReplicationStatistics [-VMName] [-PassThru] [-ComputerName ] [-WhatIf] [-Confirm]

Example

_Reset-VMReplicationStatistics -VMName Contoso-Print1_

Cmdlet

Resume-VMReplication

Description

This cmdlet is used to resume replication of the virtual machine that is passed as input and are paused currently OR used to start resynchronization for a suspended/critical state virtual machine.

Verb-Noun

Resume-VMReplication

Syntax

Resume-VMReplication [-VMName] [-ComputerName ] [-ResynchonizeStartTime ] [-Resynchronize] [-PassThru]

Example

_Resume-VMReplication -VMName CO-EXEC-DATA1_

Cmdlet

Set-VMNetworkAdapterFailoverConfiguration

Description

Configures the Failover IP settings for the n/w adapter. These IP settings will be applied to the virtual machines’s operating system whenever the virtual machines is started as part of failover.

Verb-Noun

Set-VMNetworkAdapterFailoverConfiguration

Syntax

Set-VMNetworkAdapterFailoverConfiguration [-VMName] [[-VMNetworkAdapterName] ] [-ComputerName ] [-IPv6SubnetPrefixLength ] [-IPv6Address ] [-IPv6DefaultGateway ] [-IPv6AlternateDNSServer ] [-IPv6PreferredDNSServer ] [-IPv4SubnetMask ] [-IPv4Address ] [-IPv4DefaultGateway ] [-IPv4AlternateDNSServer ] [-IPv4PreferredDNSServer ]

Example

A good example would be to use another Hyper-V cmdlet (Get-VMNetworkAdapter) to get the adapter and then make the setting changes -

Get-VMNetworkAdapter -VMName CO-EXEC-DATA1 | Set-VMNetworkAdapterFailoverConfiguration -IPv4Address 1.53.0.170 -IPv4SubnetMask 255.0.0.0 -IPv4DefaultGateway 1.0.0.3 -IPv4PreferredDNSServer 1.53.0.191

Cmdlet

Set-VMReplication

Description

This cmdlet configures the replication relationship for a virtual machine. If the virtual machine is already configured for replication, it modifies the replication relationship of the virtual machine.

Verb-Noun

Set-VMReplication

Syntax

Set-VMReplication [-VMName] [-ComputerName ] [[-ReplicaServerName] ] [[-ReplicaServerPort] ] [[-AuthenticationType] ] [-AsJob] [-PassThru] [-Reverse] [-AutoResynchronizeIntervalStart ] [-AutoResynchronizeIntervalEnd ] [-InitialReplicationStartTime ] [-AsReplica] [-RecoveryHistory ] [-ExcludedVhdPath ] [-ExcludedVhd ] [-CertificateThumbprint ] [-CompressionEnabled] [-ApplicationConsistentSnapshotFrequency ] [-DisableAppConsistentReplication] [-AutoResynchronizeEnabled]

Example

_Set-VMReplication -VMName CO-FIN-FS1 -ReplicaServerName hyp3.contoso.com -ReplicaServerPort 8080 -AuthenticationType Integrated -CompressionEnabled 1 -RecoveryHistory 0_

Cmdlet

Set-VMReplicationAuthorizationEntry

Description

This cmdlet edits an existing authorization entry for the Replica server. This cmdlet can be used to modify the following - ReplicaStorageLocation,  KeepPrimaryStorageLocation, and SecurityTag for an existing "AllowedPrimaryServer".

Verb-Noun

Set-VMReplicationAuthorizationEntry

Syntax

Set-VMReplicationAuthorizationEntry [-AllowedPrimaryServer] [[-ReplicaStorageLocation] ] [-KeepPrimaryStorageLocation] [-ComputerName ] [-PassThru]

Example

_Set-VMReplicationAuthorizationEntry -AllowedPrimaryServer hyp3.contoso.local -ReplicaStorageLocation d:\ReplicaStorage_

Cmdlet

Set-VMReplicationServer

**Description** This cmdlet is used to provision the replica server, including specification of server authentication and the default storage location to be used. Multiple types of authentication could be allowed for the replica server. If certificate based authorization is chosen, then the certificate thumbprint is required.  You can also choose to enable replication from any servers thereby adding a * entry in the Authorization list

Verb-Noun

Set-VMReplicationServer

Syntax

Set-VMReplicationServer [-KeepPrimaryStorageLocation] [-ReplicationEnabled] [[-AllowedAuthenticationType] ] [-ReplicationAllowedFromAnyServer] [-ComputerName ] [-MonitoringStartTime ] [-MonitotingInterval ] [-CertificateAuthenticationPort ] [-CertificateThumbprint ] [-PassThru] [-IntegratedAuthenticationPort ]

Example

_Set-VMReplicationServer -ReplicationEnabled 1 -AllowedAuthenticationType Integrated -IntegratedAuthenticationPort 8080 -DefaultStorageLocation d:RecoveryData  -ReplicationAllowedFromAnyServer 1_

Cmdlet

Start-VMFailover

Description

This cmdlet is used in multiple contexts - **Planned Failover**, **Failover**, and **Test Failover**.

Verb-Noun

Start-VMFailover

Syntax

Start-VMFailover [-VMName] [-Prepare] [-ComputerName ] [-PassThru] [-AsJob]

Start-VMFailover [-VMName] [-VMRecoverySnapshot]  [-Prepare] [-PassThru] [-AsJob]

Start-VMFailover [-VMName] [-ComputerName <String[]>] [-PassThru] [-Prepare] [-AsJob] [-AsTest]

Example

Planned Failover

Planned Failover is a workflow, and requires a series of cmdlets to be run in a particular order. Some cmdlets need to be run on the primary server, while others on the Replica server. Run the cmdlets in the following order:

  1. 1.     On the primary server: 1. a.      Stop-VM –VMName CO-FIN-FS1 (Shuts down the VM) 2. _New-VMReplicationAuthorizationEntry hyp3.contoso.com -ReplicaStorageLocation d:\ReplicaStorage DEFAULT _(Ensure current primary server/cluster allows current replica server/cluster to replicate. If the current primary server already authorizes the current replica server to send replication data, then this step (1b) can be skipped) 3. _Start-VMFailover -VMName CO-FIN-FS1 –prepare _(Replicates any unreplicated changes)
  2. On the Replica server: 1. _Start-VMFailover -VMName CO-FIN-FS1 _(Fails over the VM) 2. _Start-VMFailover -VMName CO-FIN-FS1 –reverse _(Resumes the replication in the reverse direction) 3. _Start-VM –VMName CO-FIN-FS1 _(Starts the VM)

Failover Start-VMFailover -VMName CO-FIN-FS1 -VMRecoverySnapshot

Test Failover Start-VMFailover -VMName CO-FIN-FS1 -AsTest

Cmdlet

Start-VMInitialReplication

Description

This cmdlet is used to start initial replication of the virtual machine. This cmdlet serves 3 purposes -

a. Starts Initial replication and Delta replication at the end of IR.

b. Starts initial replication if the Initial replication was cancelled manually by an administrator

c. Starts initial replication if the replication stopped due to some unrecoverable failure

Verb-Noun

Start-VMInitialReplication

Syntax

Start-VMInitialReplication [-VMName] [-ComputerName ] [-PassThru] [-DestinationPath ] [-AsJob]

Example

Online initial replication:

Start-VMInitialReplication –VMName CO-FIN-FS1

Initial replication using external media:

Start-VMInitialReplication –VMName CO-FIN-FS1 –DestinationPath “F:\ExportData”

Initial replication seeding from backup copy on Replica server

On Replica server

_Set-VMReplication VM01 –AsReplica –AllowedPrimaryServer hyp3.contoso.local _

On primary server

Start-VMInitialReplication –VMName CO-FIN-FS1 -UseBackup

Cmdlet

**Stop-VMFailover**

Description

This cmdlet allows the admin to cancel the ongoing failover of a virtual machine or the test failover for the virtual machine.

Verb-Noun

Stop-VMFailover

Syntax

Stop-VMFailover [-VMName] [-ComputerName ] [-PassThru]

Example

_Stop-VMFailover –VMName CO-FIN-FS1_

Cmdlet

Stop-VMInitialReplication

Description

This cmdlet is used to cancel the online Initial Replication that is going on. This cmdlet can also be used to cancel the ongoing export/import of OOB IR.

Verb-Noun

Stop-VMInitialReplication

Syntax

Stop-VMInitialReplication [-VMName] [-ComputerName ] [-PassThru]

Example

_Stop-VMInitialReplication -VMName CO-FIN-FS1_

Cmdlet

Stop-VMReplication

Description

This cmdlet is used to cancel the resync Replication that is going on.

Verb-Noun

Stop-VMReplication

Syntax

Stop-VMReplication [-VMName] [-ComputerName ] [-PassThru]

Example

_Stop-VMReplication -VMName CO-FIN-FS1_

Cmdlet

Suspend-VMReplication

**Description** This cmdlet pauses replication in the virtual machine that is passed as input.

Verb-Noun

Suspend-VMReplication

Syntax

Suspend-VMReplication [-VMName] [-ComputerName ] [-PassThru]

Example

_Suspend-VMReplication -VMName CO-EXEC-DATA1_

Cheers,

Marcos Nogueira azurecentric.com Twitter: @mdnoga

Search