Korfu's Posts

Ok a little more info, it works if i close and reopen the powershell window.  Is it possible its storing the System.Exception ?? Is there a way to clear it after each run?
Ok a little more info, it works if i close and reopen the powershell window.  Is it possible its storing the System.Exception ?? Is there a way to clear it after each run?
If i put the ErrorAction stop it catches the error but then also executes the catch even on successes.  I have noticed that it executes the catch before the snapshot can finish, it has barely sta... See more...
If i put the ErrorAction stop it catches the error but then also executes the catch even on successes.  I have noticed that it executes the catch before the snapshot can finish, it has barely started by the time it executes the catch action.
Ok so my goal is to create a script that will automate creating a snapshot of a server but will catch errors and send an email based off the error.  From what I can tell Try/Catch blocks will... See more...
Ok so my goal is to create a script that will automate creating a snapshot of a server but will catch errors and send an email based off the error.  From what I can tell Try/Catch blocks will be the best way to accomplish this.  This is what I have so far but I cant get it to catch the error. Here is the snippet of the code try { Get-VM $serverVMName | new-snapshot -Name "dppfr-$serverVMName-$TimeStr" -Description "Automated backup"  } catch [system.exception] { sendError } Any thoughts?