1

In python you can do something like:

if __name__ == '__main__':
    # stuff

Is there any way in PS to achieve this functionality? I want to separate ps files that only have cmdlets inside them from the ones that are actually runnable and do stuff.

Vivere
  • 1,919
  • 4
  • 16
  • 35
  • Not really. "I want to separate ps files that only have cmdlets inside them from the ones that are actually runnable and do stuff." what's stopping you from doing just that? – Mathias R. Jessen Mar 08 '21 at 16:20
  • @MathiasR.Jessen for example dot sourcing a ps file that has only cmdlets will load those cmdlets into the current session. Doing the same to a script that has cmdlets and also some lines of logic, those lines will get run. I would like to have a way of telling my script to only run things when it is called/executed. In my project, I made a convention that the ps files that only have cmdlets to export are suffixed with some word. But I wonder if others will mentain my convention so that's why I would like to "impose" it let's say. – Vivere Mar 08 '21 at 16:32

0 Answers0