Hello,
I am trying to do a simple planned failover via PowerShell.
My Azure Site Recovery is connected via VMM.<o:p></o:p>
Basically I just want to do the same think in
PowerShell which is done if I klick on a VM and select Failover->PlannedFailover
I know about this PowerShell let Start-AzureSiteRecoveryPlannedFailoverJob
https://msdn.microsoft.com/library/d7b03598-b1b7-448b-b336-b65cb4243bd1
But I can't get it to work. I already tried a couple of different things.
Even if I use the sample from the bottom of the page I get an error:
Sample:
PS C:\> $Container = Get-AzureSiteRecoveryProtectionContainer PS C:\> $Protected = Get-AzureSiteRecoveryProtectionEntity -ProtectionContainer $Container PS C:\> Start-AzureSiteRecoveryPlannedFailoverJob -Direction PrimaryToRecovery -ProtectionEntity $Protected -Optimize ForDowntime
Error:
Start-AzureSiteRecoveryPlannedFailoverJob : Cannot convert 'System.Object[]' to the type 'Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProtectionEntity' required by parameter 'ProtectionEntity'. Specified method is not supported. At line:3 char:90 + ... otectionEntity $Protected -Optimize ForDowntime + ~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Start-AzureSite...nnedFailoverJob], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Azure.Commands.RecoveryServices.StartAzureSiteRecoveryPlannedFailoverJob
I also tried this and a couple of other approaches:
$container = Get-AzureSiteRecoveryProtectionContainer -Name "TestBurst" $VM = Get-AzureSiteRecoveryVM -Name "SitRecoveryTest" -ProtectionContainerId $container.ID $Entity = Get-AzureSiteRecoveryProtectionEntity -ProtectionContainerId $container.ID | Where-Object{($_.Name -match 'SitRecoveryTest')} Start-AzureSiteRecoveryPlannedFailoverJob -ProtectionEntity $Entity[0] -Optimize ForDowntime -Direction PrimaryToRecovery
But here I get the following Error:
Start-AzureSiteRecoveryPlannedFailoverJob : Operation failed. ClientRequestId: 2bd800fc-b75e-4900-9f80-8cfb89704abb-2015-06-21 23:10:10Z-P InvalidParameter: <Error xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Azure.SiteRecovery"> <ActivityId>00000000-0000-0000-0000-000000000000</ActivityId> <Code>InvalidParameter</Code> <Message>An invalid parameter ReplicationProvider was passed.</Message> <PossibleCauses>Parameter value is not correct for this action.</PossibleCauses> <RecommendedAction>Correct the parameter value and retry the last action. If the issue persists, contact Support.</RecommendedAction> </Error> At line:16 char:1 + Start-AzureSiteRecoveryPlannedFailoverJob -ProtectionEntity $Entity[0] -Optimize ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Start-AzureSite...nnedFailoverJob], SerializationException + FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.StartAzureSiteRecoveryPlannedFailoverJobIf
If I change the parameter -Direction to RecoveryToPrimary I even get the right Error that the FailoverDirectionNotCorrect is incorrect
I thought it would be a relatively easy task to do in PowerShell but after nearly two hours of trying different thinks I am stuck.
I also tried a couple of different thinks but I don't think I should post all my failed attempts here ;) Two is enought
Kind regards
Pascal
- Edited by Pascal90909 Sunday, June 21, 2015 11:20 PM