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?
I tried adding 2> "OutputPath" at the end to stream the output to this location but it did not work.
$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
Get-ACL,Set-ACL, and$objACL.AddAccessRule()(which doesn't return a value) are the only expressions not captured in variables, so that's all you should see. Why are you using2>specifically?