1

I need you help Im using the next script: How to get all groups within all webs in SharePoint 2010 using Powershell

The script perfectly, but some user can not be found, so I'm trying to control the errors and send them to a file, I try:

catch [System.Exception]{
    "ERROR: " + $($_.Exception.Message)| out-file $logfile -append
}

But this does not work, the catch never write the file as if it never entered in the catch, but in screen I see the errors

3
  • Marco: can you please confirm what you mean by does not work? Commented Jan 5, 2015 at 15:24
  • the catch never write the file as if it never entered in the catch, but in screen I see the errors
    – Marco
    Commented Jan 5, 2015 at 15:26
  • Marco: Please post your complete code. Powershell error handling works in a different way. Commented Jan 5, 2015 at 15:35

1 Answer 1

0

I don't think you need all of that. Try just:

catch {
    "Error: " + $_.Exception.Message | out-file $logfile -append
}
1
  • didn't work, see the attached image onedrive.live.com/… idk how to attach images in comments
    – Marco
    Commented Jan 5, 2015 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.