title: How to output result of a PowerShell script to a text file
body: <p>I am using this script to add users to folder permission. How can I output the result of this script (success or failure) to a text file?</p>
  
  <p>I tried adding <code>2&gt; "OutputPath"</code> at the end to stream the output to this location but it did not work.</p>
  
  <pre><code>$ProjectName = "ProjetName"
  $Folder = "FolderPath" + $ProjectName
  Get-Acl $Folder
  $ColRights = [System.Security.AccessControl.FileSystemRights]"Modify, ListDirectory"
  $InheritanceFlagSetting = @("ContainerInherit","ObjectInherit")
  $PropagationFlagSetting = "None"
  $InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]$InheritanceFlagSetting
  $PropagationFlag = [System.Security.AccessControl.PropagationFlags]$PropagationFlagSetting
  $objType =[System.Security.AccessControl.AccessControlType]::Allow
  $objUser = New-Object System.Security.Principal.NTAccount("Username")
  $objACE = New-Object System.Security.AccessControl.FileSystemAccessRule ($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType)
  
  #Get the ACL for the folder (so we can add to it)
  $objACL = Get-Acl $Folder
  $objACL.AddAccessRule($objACE)
  
  #publish the new ACL with additional rule
  Set-Acl $Folder $objACL
  </code></pre>