I have an XML file with the following structure:
<ReportParameters>
<Parameter id="mxrNZh/4cyLB/qExTbTjCg==" subreportfilter="True">
<Name>Absence Start Date</Name>
<Type>DateRange</Type>
<PromptText>Absence Start Date is between</PromptText>
<Values>
<DateRange>
<Start>2022-04-21T13:45:35</Start>
<End>2023-04-21T13:45:35</End>
</DateRange>
</Values>
</Parameter>
<Parameter id="mxrNZh/4cyLB/qExTbTjCg==" subreportfilter="True">
<Name>Absence Start Date</Name>
<Type>DateRange</Type>
<PromptText>Absence Start Date is between</PromptText>
<Values>
<DateRange>
<Start>2022-04-21T13:43:01</Start>
<End>2023-04-21T13:43:01</End>
</DateRange>
</Values>
</Parameter>
<Parameter id="mxrNZh/4cyLB/qExTbTjCg==" subreportfilter="True">
<Name>Absence Start Date</Name>
<Type>DateRange</Type>
<PromptText>Absence Start Date is between</PromptText>
<Values>
<DateRange>
<Start>2022-04-21T11:51:40</Start>
<End>2023-04-21T11:51:40</End>
</DateRange>
</Values>
</Parameter>
<Parameter id="mxrNZh/4cyLB/qExTbTjCg==" subreportfilter="True">
<Name>Absence Start Date</Name>
<Type>DateRange</Type>
<PromptText>Absence Start Date is between</PromptText>
<Values>
<DateRange>
<Start>2022-04-21T13:11:49</Start>
<End>2023-04-21T13:11:49</End>
</DateRange>
</Values>
</Parameter>
</ReportParameters>
When I try
$xmldocument = [xml](Get-Content "params.xml")
$xmldocument.reportparameters.parameter.values.DateRange.start = (Get-Date).AddYears(-2).ToString("yyyy-MM-ddTHH:mm:ss")
I get the error that says property start is not found. When I remove the three duplicate nodes at the end of the file so only a single one remains, it works.
In order for the program I'm running to work, it needs all 4 nodes. I'm just trying to change the date (to the same date) of each one. Is there any way to do this?