VMware Cloud Community
ChittraM
Enthusiast
Enthusiast

how to capture error message of commands tun using -runasync paramter

Am deploying multiple vms by running the below commad,

> new-vm -vmhost <hostname> -name <vmname> -template <temp_name> -datastore <datastore_name> -runasync

So the prompt is immediately returned and the command runs in the background.

now i have to collect the error messages if any from the output of the above command.

using get-task i can only find if the state of the task is "success" or "error"

Is there any command or parameter of get-task from where i can get the actual error message as why the command would have failed?

0 Kudos
2 Replies
RvdNieuwendijk
Leadership
Leadership

Take a look at Luc's "SDK Best Practices" blog post. The example under "Handle Faults Carefully" will probably solve your question.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
ChittraM
Enthusiast
Enthusiast

Amazing.. that solved my problem..

0 Kudos