Quantcast
Channel: MarcosNogueiraOrg - Virtualization 4 All » Power Shell
Viewing all articles
Browse latest Browse all 8

Hyper-V Replica PowerShell CMDLETS

$
0
0

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] <String> [-ComputerName <String[]>] [-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] <String[]> [[-VMNetworkAdapterName] <String[]>] [-ComputerName <String[]>]
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] <String[]>] [-ComputerName <String[]>] [-ReplicaServerName <String>] [-PrimaryServerName <String>] [-State <String>] [-ReplicationTag <String>]
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] <String>] [-ComputerName <String[]>] [-ReplicaStorageLocation <String
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] <String[]>]
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] <String> [-ComputerName <String[]>] [-Path] <String> [-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] <String[]>] [-ReplicaServerName <String>] [-ComputerName <String[]>] [-ReplicationTag <String>] [-State <String>] [-PrimaryServerName <String>]
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] <String> [-ComputerName <String[]>]
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] <String> [-ComputerName <String[]>] [-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] <String> [-ComputerName <String[]>] [-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] <string[]> [-PassThru] [-ComputerName <string[]>] [-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] <String> [-ComputerName <String[]>] [-ResynchonizeStartTime <DateTime>] [-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] <String[]> [[-VMNetworkAdapterName] <String[]>] [-ComputerName <String[]>] [-IPv6SubnetPrefixLength <String>] [-IPv6Address <String>] [-IPv6DefaultGateway <String>] [-IPv6AlternateDNSServer <String>] [-IPv6PreferredDNSServer <String>] [-IPv4SubnetMask <String>] [-IPv4Address <String>] [-IPv4DefaultGateway <String>] [-IPv4AlternateDNSServer <String>] [-IPv4PreferredDNSServer <String>]
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] <String> [-ComputerName <String[]>] [[-ReplicaServerName] <String>] [[-ReplicaServerPort] <Int32>] [[-AuthenticationType] <String>] [-AsJob] [-PassThru] [-Reverse] [-AutoResynchronizeIntervalStart <DateTime>] [-AutoResynchronizeIntervalEnd <DateTime>] [-InitialReplicationStartTime <DateTime>] [-AsReplica] [-RecoveryHistory <Int32>] [-ExcludedVhdPath <String[]>] [-ExcludedVhd <Microsoft.Vhd.PowerShell.VirtualHardDisk[]>] [-CertificateThumbprint <String>] [-CompressionEnabled] [-ApplicationConsistentSnapshotFrequency <Int32>] [-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] <String> [[-ReplicaStorageLocation] <String>] [-KeepPrimaryStorageLocation] [-ComputerName <String[]>] [-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] <Enum>] [-ReplicationAllowedFromAnyServer] [-ComputerName <String[]>] [-MonitoringStartTime <DateTime>] [-MonitotingInterval <TimeSpan>] [-CertificateAuthenticationPort <Int32>] [-CertificateThumbprint <String>] [-PassThru] [-IntegratedAuthenticationPort <Int32>]

 

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] <String> [-Prepare] [-ComputerName <String[]>] [-PassThru] [-AsJob]

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

Start-VMFailover [-VMName] <String> [-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] <String> [-ComputerName <String[]>] [-PassThru] [-DestinationPath <String>] [-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] <String> [-ComputerName <String[]>] [-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] <String> [-ComputerName <String[]>] [-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] <String> [-ComputerName <String[]>] [-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] <String> [-ComputerName <String[]>] [-PassThru]
Example Suspend-VMReplication -VMName CO-EXEC-DATA1

Filed under: Hyper-V, Hyper-V Replica, Power Shell Tagged: Hyper-V, Hyper-V Replica, Power Shell

Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images