PowerShell script exchange
Post Reply
masonit
Service Provider
Posts: 325
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Add-VBRViJobObject, Remove-VBRJobObject error handling

Post by masonit »

Hi

When using Add-VBRViJobObject and I add a vm to a job. Information is returned about the added vm. But If I try to add same vm again nothing happens. Shouldn't I get an error saying like "vm already in job".

Same thing with Remove-VBRJobObject. If I try to remove a object that is already removed. No errors is reported. Nothing like "vm not present in job".

Shouldn't there by any error handling?

\Masonit
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add-VBRViJobObject, Remove-VBRJobObject error handling

Post by veremin »

Currently, those warnings do not exist in PowerShell.

If you want to handle this situation somehow, you will need to automatically check whether any information is returned regarding VM added; if not, it will mean that VM has been already added to the selected job.

Thanks!
masonit
Service Provider
Posts: 325
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Add-VBRViJobObject, Remove-VBRJobObject error handling

Post by masonit »

Ok. Information is only returned from Add-VBRViJobObject, not from Remove-VBRJobObject. But I could always check the job objects again to verify that vm is either added or removed.

\Masonit
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add-VBRViJobObject, Remove-VBRJobObject error handling

Post by veremin »

Correct, checking the number of objects afterwards sounds also like a good idea. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests