Good morning, long time post sponger, first time poster here.
I'm not bad with Powershell but quite bad with XML and I'm failing to do something that seems very simple.
I have written/adapted a script to download data from an FTP site uploaded since a given datetime, which sounds hard, but wasn't too bad. Then I need towrite back the current datetime to the XML file, which sounds easy but I can't seem to do.
2 examples from the XML file:
<DataFetch version="1.0">
<DSource>
<Source>/incoming/Source1/</Source>
<Destination>C:\Temp\Source1</Destination>
<Mask>*.zip</Mask>
<ModDate>15 July 2015 00:00:00</ModDate>
</DSource>
<DSource>
<Source>/incoming/Source2/</Source>
<Destination>C:\Temp\Source2</Destination>
<Mask>*.xls?</Mask>
<ModDate>10 July 2015 00:00:00</ModDate>
</DSource>
</DataFetch>
The relevant part of the Powershell:
[xml]$XMLvar = Get-content .\DataFetch.xml
foreach( $DSource in $XMLvar.DataFetch.DSource)
{
$CurrDate = (get-date) -as [string]
$Source = $DSource.Source
$Dest = $DSource.Destination
$Mask = $DSource.Mask
$ModDate = $DSource.ModDate
$ModDate.setattribute = $CurrDate
# $node = $DSource.ModDate
# $node = $CurrDate
# #$xml.updateattribute $DSource.ModDate,$CurrDate
# $node
}
All of the commented out lines are bit of things I've tried that don't work at all, can anyone help?