VMware Cloud Community
olegarr
Enthusiast
Enthusiast

Equivalent of "goto" command?

Hello:

I could not find if there is equivalent of "goto" command (pretty sure it should be)... Can some one point me out, please?

I want to check, if baseline with specific name exists, and if it's not then skip couple steps in my script...

Thank you

0 Kudos
2 Replies
LucD
Leadership
Leadership

PowerShell is an object-oriented language not a procedural language, hence there is no equivalent of the goto command.

I haven't seen a situation that you can't solve without using a goto statement.

You could do for example

if (<test if baseline exists>){
   <execute the baseline specific statements>
}
<continue with the rest of your script>

Or even more OOP (at least in my opinion)

... | Where-Object -filter <check baselinename> | <baseline specific instructions>


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

olegarr
Enthusiast
Enthusiast

Luc,

Thank you very much for your help.

olegarr

0 Kudos