c# powershell invoke error handling