1

I am not sure if I am missing something obvious but I am trying to use New-EDRSReplicationConfigurationTemplate text

from the AWS.Tools.Drs package text.

I cannot see how to define -PitPolicy <PITPolicyRule[]>. It looks like it takes a bool, a few integers and a constant text.

I have tried numerous ways of passing the information for example;

[PSCustomObject[]] $pitPol = @("interval=4", "retentionDuration=168", "units=HOUR")

but always end up with messages of the nature cannot convert what I am passing to the type: Amazon.Drs.Model.PITPolicyRule

enter image description here

given values for interval=4, retentionDuration=168, units="HOUR" how am I supposed to construct <PITPolicyRule[]?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Matt
  • 11
  • 1

1 Answers1

0

I cannot verify this solution, but the information in your question suggests that the following may work:

$pitPol = [Amazon.Drs.Model.PITPolicyRule] @{
  interval = 4
  retentionDuration = 168
  units = 'HOUR'
}

This assumes that the [PITPolicyRule] class has a (public) parameter-less constructor, which does appear to be the case, based on your alternative documentation link).

The above causes PowerShell to construct a [PITPolicyRule] instance behind the scenes and make it set its properties based on the entries matching the property names in the hashtable @{ ... }) being used in the cast; see this answer for more information about this object-initialization technique.

Note that even though the -PitPolicy is declared to accept an array of PitPolicyRule values, PowerShell's parameter binder allows you to pass a single instance of the declared type as well.

mklement0
  • 382,024
  • 64
  • 607
  • 775