I have been tasked with performing monthly maintenance on an xmla file. The file should contain the latest three year/month combinations. Below is the relevant part of the file and how it appears now:
<PartitionID>TRANSACTIONS 201412</PartitionID>
<PartitionID>TRANSACTIONS 201501</PartitionID>
<PartitionID>TRANSACTIONS 201502</PartitionID>
I have written a script to grab and change the dates based off the current month. The problem with this logic is if the months are off by just one in the file to begin with my logic won't work. For example, the code below is how I change the oldest month:
$monthMinus2 = (Get-Date).AddMonths(-2) | Get-Date -Format "yyyyMM"
$monthMinus3 = (Get-Date).AddMonths(-3) | Get-Date -Format "yyyyMM"
$xmla = Get-Content $PROCESS2PERIODSFILE
$xmla | % { $_.Replace($monthMinus3, $monthMinus2) } | Set-Content $PROCESS2PERIODSFILE
This is a little too fragile and I am looking for a more robust solution.
I have been thinking that if I can somehow select the year and month (no matter the combination), add the two values together and then perform the maintenance based of high, middle, and low sum that I can run this maintenance script at anytime throughout the year, no matter the current values in the file and get the correct result.
To be more specific, I need a way to select the month/year combination (no matter the value). Can this be done be done but utilizing the xmla tag, ?
Then perform addition on the first four nums and the last two nums. Not sure at all how to go about this part at all.
Then some if blocks to change the values based off the highest, middle, and lowest number.
I realize this is complicated so please ask any questions. Was trying not to create a wall of text. Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire