$File = "C:\Users\hubert.cornet\Downloads\rules-010.xml"

clear

$Mag       = $Null
$FinalData = $Null
$RANK      = 30

For ($Num = 1 ;$Num -le 243 ; $Num++) {
    $RANK       = 10
    $RANK       = $RANK + $Num

    $measureNum = $Num | Measure-Object -Character

    If ($measureNum.Characters -eq 1 ) {
        $Mag = "00"+$Num
    }
    ElseIf ($measureNum.Characters -eq 2 ) {
        $Mag = "0"+$Num
    }
    ElseIf ($measureNum.Characters -eq 3 ) {
        $Mag = $Num
    }
    Else {

    }

    $DataTexte = "
  <rule>
    <entities_id>Saint-Maclou</entities_id>
	<sub_type>RuleLocation</sub_type>
	<ranking>$RANK</ranking>
	<name>MAG$Mag</name>
	<description></description>
	<match>AND</match>
	<is_active>1</is_active>
	<comment></comment>
	<is_recursive>0</is_recursive>
	<uuid>500717c8-2bd6e957-53a12b5fd45f84.20365$Mag</uuid>
	<condition>0</condition>
	<date_creation></date_creation>
	<rulecriteria>
	  <criteria>tag</criteria>
	  <condition>0</condition>
	  <pattern>MAG$Mag</pattern>
	</rulecriteria>
	<ruleaction>
	  <action_type>assign</action_type>
	  <field>locations_id</field>
	  <value>Magasins &amp;#62; MAG$Mag</value>
	</ruleaction>
  </rule>"

    $FinalData += $DataTexte
}

Add-Content $File $FinalData
