Do powershell parameters need to be at the front of the script?

Question:

I’m trying to have a script with both executable code and a function, like the following:

However, I run into the following error: “The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property”

When I list my function at the end of the file, it says that the function name is undefined. How do I call a powershell function from executable code within the same script?

Answer:

The correct order is:

1.Script parameters

2.Function definitons

3.Script code

Why would you want it any other way?

Source:

Do powershell parameters need to be at the front of the script? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply