title: Can't make my log file work for my user profile script
body: <p>So, to make it simple, i'm trying to copy user profiles through a shared folder on multiple clients, it works fine, but i can't seem to make a log file that works with it</p>
  <p>As it is, i expected that $? would always end up giving me True for each command (Unless it kinda crashes in the middle of copying), since it's properly copying every folder i want, but it's not... It gives me a True once, then it's all false, even though it did everything correctly</p>
  <pre><code>    Foreach ($User in $Users){
          Foreach ($TargetDirectory in $Directories){            
              $TestPath = Test-Path -Path &quot;\\$Client\Users\$User&quot;
              If ($TestPath -eq $True) {   
                              
                  Robocopy &quot;\\$Client\Users\$User\$TargetDirectory&quot; &quot;C:\SAV\$Client\$User\$TargetDirectory&quot; /E /MIR
                  
                  $Date = get-date -f yyyy-MM-dd
                  $Path = &quot;C:\Logs\($Date)Sauvegarde_Profils_$Client.txt&quot;
                  New-Item -Path $Path -Force
                  $Result = &quot;Copie du dossier $TargetDirectory, appartenant à $User = $? dans $Client&quot;
                  Add-Content -Path $Path $Result
              }
          }
      }
  }
  </code></pre>
  <p>Here's a sample of the logfile (in French, but it's just to show that it's almost working as intended) :</p>
  <p>Copie du dossier Documents, appartenant à firmerie.alain = True pour CLIENT-1</p>
  <p>Copie du dossier Desktop, appartenant à firmerie.alain = False pour CLIENT-1</p>
  <p>...(Only False after that point)</p>