Asked by:
Object reference not set to an instance of an object. Error when running command Get-AzureRmRecoveryServicesAsrRecoveryPlan

Question
-
PS C:\WINDOWS\system32> $rpname = "myrecoveryplan"
$recoplan = Get-AzureRmRecoveryServicesAsrRecoveryPlan -Name $rpname
Get-AzureRmRecoveryServicesAsrRecoveryPlan : Operation failed.
Object reference not set to an instance of an object.
At line:2 char:13
+ $recoplan = Get-AzureRmRecoveryServicesAsrRecoveryPlan -Name $rpname
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmReco...AsrRecoveryPlan], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.GetAzureRmRecoveryS
ervicesAsrRecoveryPlan- Moved by Bill_Stewart Friday, July 27, 2018 6:15 PM This is not "scripts on demand"
Thursday, April 19, 2018 5:14 AM
All replies
-
PS C:\WINDOWS\system32> $rpname = "myrecoveryplan"
$recoplan = Get-AzureRmRecoveryServicesAsrRecoveryPlan -Name $rpname
Get-AzureRmRecoveryServicesAsrRecoveryPlan : Operation failed.
Object reference not set to an instance of an object.
At line:2 char:13
+ $recoplan = Get-AzureRmRecoveryServicesAsrRecoveryPlan -Name $rpname
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmReco...AsrRecoveryPlan], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.GetAzureRmRecoveryS
ervicesAsrRecoveryPlan- Merged by jrv Thursday, April 19, 2018 6:18 AM DUPLICATE
Thursday, April 19, 2018 5:02 AM -
Are you running the latest Azure modules???
\_(ツ)_/
Thursday, April 19, 2018 6:14 AM -
Yes Siterecovery module version is 5.0.6. below is powershell version:
Name Value
---- -----
PSVersion 5.1.16299.251
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.251
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1Thursday, April 19, 2018 6:57 AM -
No. The Azure modules.
Are you logged into Azure?
\_(ツ)_/
Thursday, April 19, 2018 7:08 AM -
Ok I have updated My powershell again and it seems moving on now. But I got another blocker. Coud you please help:
PS C:\WINDOWS\system32> $rpname = "myrecoveryplan"
$Vault=Get-AzureRmRecoveryServicesVault -Name "testvault"
$Context= Set-AzureRmRecoveryServicesAsrVaultContext -Vault $Vault
$recoplan = Get-AzureRmRecoveryServicesAsrRecoveryPlan -Name $rpname
Start-AzureRmSiteRecoveryTestFailoverJob -RecoveryPlan $recoplan -Direction "PrimaryToRecovery" -VMNetwork "asrtestfailtarget"
Start-AzureRmSiteRecoveryTestFailoverJob : Cannot bind parameter 'RecoveryPlan'. Cannot convert the
"Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRRecoveryPlan" value of type
"Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRRecoveryPlan" to type
"Microsoft.Azure.Commands.SiteRecovery.ASRRecoveryPlan".
At line:5 char:56
+ ... rt-AzureRmSiteRecoveryTestFailoverJob -RecoveryPlan $recoplan -Direct ...
+ ~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Start-AzureRmSiteRecoveryTestFailoverJob], Parameter
BindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.SiteRecovery.Start
AzureRmSiteRecoveryTestFailoverJobThursday, April 19, 2018 7:17 AM -
Where did you get this script?
How did you update your Azure modules?
\_(ツ)_/
Thursday, April 19, 2018 7:20 AM -
I have used this command to update site recovery module install-module -Name azurerm.siterecovery -force
I am following microsoft powershell gallery to provide appropriate parameters.
Thursday, April 19, 2018 7:45 AM -
Update-Module azurerm
You must update all azure modules as a set. This does that.
\_(ツ)_/
Thursday, April 19, 2018 7:49 AM -
Hi,
I am getting below error when I run Get-AzureRmRecoveryServicesAsrRecoveryPlan command in Azure Automation Runbook.
I have imported AzureRM.RecoveryServices.SiteRecovery & Newtonsoft.Json modules in automation account. Could you please suggest what can go wrong here:
Get-AzureRmRecoveryServicesAsrRecoveryPlan : Operation failed. ClientRequestId: 369ff6b3-413f-4b06-a96b-3c6d691f0ab0-2018-04-23 15:14:33Z-Ps Method not found: 'Newtonsoft.Json.Serialization.IAttributeProvider Newtonsoft.Json.Serialization.JsonProperty.get_AttributeProvider()'. At line:77 char:19 + $RecoveryPlans = Get-AzureRmRecoveryServicesAsrRecoveryPlan | %{ $_. ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-AzureRmReco...AsrRecoveryPlan], Exception + FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.GetAzureRmRecoveryServicesAsrRecoveryPlan
- Merged by jrv Tuesday, April 24, 2018 11:13 AM DUPLICATET
Tuesday, April 24, 2018 9:49 AM