/// <summary>
        ///     Creates an E2A Policy Object
        /// </summary>
        private void HyperVToAzurePolicyObject()
        {
            if (string.Compare(
                    this.ReplicationProvider,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase) !=
                0)
            {
                throw new InvalidOperationException(
                          string.Format(
                              Resources.IncorrectReplicationProvider,
                              this.ReplicationProvider));
            }

            PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime);

            var replicationFrequencyInSeconds =
                PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(
                    this.ReplicationFrequencyInSeconds);

            var hyperVReplicaAzurePolicyInput = new HyperVReplicaAzurePolicyInput
            {
                ApplicationConsistentSnapshotFrequencyInHours =
                    this.ApplicationConsistentSnapshotFrequencyInHours,
                OnlineReplicationStartTime =
                    this.ReplicationStartTime == null ? null : this.ReplicationStartTime.ToString(),
                RecoveryPointHistoryDuration = this.NumberOfRecoveryPointsToRetain,
                ReplicationInterval          = replicationFrequencyInSeconds
            };

            hyperVReplicaAzurePolicyInput.StorageAccounts = new List <string>();

            if (this.RecoveryAzureStorageAccountId != null)
            {
                var storageAccount = this.RecoveryAzureStorageAccountId;
                hyperVReplicaAzurePolicyInput.StorageAccounts.Add(storageAccount);
            }

            var createPolicyInputProperties =
                new CreatePolicyInputProperties
            {
                ProviderSpecificInput = hyperVReplicaAzurePolicyInput
            };

            var createPolicyInput =
                new CreatePolicyInput {
                Properties = createPolicyInputProperties
            };

            var response = this.RecoveryServicesClient.CreatePolicy(
                this.Name,
                createPolicyInput);

            var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails(
                PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            this.WriteObject(new ASRJob(jobResponse));
        }
        /// <summary>
        ///     Creates an E2E Policy object
        /// </summary>
        private void EnterpriseToEnterprisePolicyObject()
        {
            if ((string.Compare(
                     this.ReplicationProvider,
                     Constants.HyperVReplica2012,
                     StringComparison.OrdinalIgnoreCase) !=
                 0) &&
                (string.Compare(
                     this.ReplicationProvider,
                     Constants.HyperVReplica2012R2,
                     StringComparison.OrdinalIgnoreCase) !=
                 0))
            {
                throw new InvalidOperationException(
                          string.Format(
                              Resources.IncorrectReplicationProvider,
                              this.ReplicationProvider));
            }

            PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime);

            var replicationFrequencyInSeconds =
                PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(
                    this.ReplicationFrequencyInSeconds);

            var createPolicyInputProperties = new CreatePolicyInputProperties();

            if (string.Compare(
                    this.ReplicationProvider,
                    Constants.HyperVReplica2012,
                    StringComparison.OrdinalIgnoreCase) ==
                0)
            {
                createPolicyInputProperties.ProviderSpecificInput = new HyperVReplicaPolicyInput
                {
                    AllowedAuthenticationType = (ushort)(string.Compare(
                                                             this.Authentication,
                                                             Constants.AuthenticationTypeKerberos,
                                                             StringComparison.OrdinalIgnoreCase) ==
                                                         0 ? 1 : 2),
                    ApplicationConsistentSnapshotFrequencyInHours =
                        this.ApplicationConsistentSnapshotFrequencyInHours,
                    Compression =
                        this.MyInvocation.BoundParameters.ContainsKey(
                            Utilities.GetMemberName(() => this.Compression)) ? this.Compression
                            : Constants.Disable,
                    InitialReplicationMethod = string.Compare(
                        this.ReplicationMethod,
                        Constants.OnlineReplicationMethod,
                        StringComparison.OrdinalIgnoreCase) ==
                                               0 ? "OverNetwork" : "Offline",
                    OnlineReplicationStartTime = this.ReplicationStartTime.ToString(),
                    RecoveryPoints             = this.NumberOfRecoveryPointsToRetain,
                    ReplicaDeletion            =
                        this.MyInvocation.BoundParameters.ContainsKey(
                            Utilities.GetMemberName(() => this.ReplicaDeletion))
                            ? this.ReplicaDeletion : Constants.NotRequired,
                    ReplicationPort = this.ReplicationPort
                };
            }
            else
            {
                createPolicyInputProperties.ProviderSpecificInput =
                    new HyperVReplicaBluePolicyInput
                {
                    AllowedAuthenticationType = (ushort)(string.Compare(
                                                             this.Authentication,
                                                             Constants
                                                             .AuthenticationTypeKerberos,
                                                             StringComparison
                                                             .OrdinalIgnoreCase) ==
                                                         0 ? 1 : 2),
                    ApplicationConsistentSnapshotFrequencyInHours =
                        this.ApplicationConsistentSnapshotFrequencyInHours,
                    Compression =
                        this.MyInvocation.BoundParameters.ContainsKey(
                            Utilities.GetMemberName(() => this.Compression)) ? this.Compression
                                : Constants.Disable,
                    InitialReplicationMethod = string.Compare(
                        this.ReplicationMethod,
                        Constants.OnlineReplicationMethod,
                        StringComparison.OrdinalIgnoreCase) ==
                                               0 ? "OverNetwork" : "Offline",
                    OnlineReplicationStartTime = this.ReplicationStartTime.ToString(),
                    RecoveryPoints             = this.NumberOfRecoveryPointsToRetain,
                    ReplicaDeletion            =
                        this.MyInvocation.BoundParameters.ContainsKey(
                            Utilities.GetMemberName(() => this.ReplicaDeletion))
                                ? this.ReplicaDeletion : Constants.NotRequired,
                    ReplicationFrequencyInSeconds = replicationFrequencyInSeconds,
                    ReplicationPort = this.ReplicationPort
                };
            }

            var createPolicyInput =
                new CreatePolicyInput {
                Properties = createPolicyInputProperties
            };

            var responseBlue = this.RecoveryServicesClient.CreatePolicy(
                this.Name,
                createPolicyInput);

            var jobResponseBlue = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails(
                PSRecoveryServicesClient.GetJobIdFromReponseLocation(responseBlue.Location));

            this.WriteObject(new ASRJob(jobResponseBlue));
        }