(Please keep in mind I'm not a system admin so I don't have Admin permissions on the share. Some departments are allowed Full Control permissions on their shared drives, and they sometimes blow out permissions accidentally and I am forced to identify and submit tickets to get them fixed. Not a great environment, I know...but it is what it is and I have to deal with it)
My code is:
- $null=(Get-ChildItem W:\ -Recurse -Force -ErrorVariable FailedItems -ErrorAction SilentlyContinue)
- foreach ($faileditem in $failedItems){
- $done = ($faileditem.CategoryInfo.reason)+","+($faileditem.CategoryInfo.targetname)
- Add-Content c:\outputfiles\ScanErrors.txt -value $done
- }