You're running a script block on a remote machine and the code is returning a PSCustomObject. Have the Catch block modify a variable with a distinctive value (e.g. "failure"), and have the Try block modify that same variable with something like "success". Add that value to the PSCustomObject and also add the name of the server to the PSCustomObject, then have the invoking script run the Invoke-Command again for each server that recoded a failure.
powershell function
Sara
421
Reputation points
How to define a small function on the above script(line 33) to easily loop through the servers on an error using try/catch to go back and look at the server again for any errors.Any suggestions is highly appreciated