In powershell, is it possible to enforce naming of arguments?

Question:

Given a script foo.ps1: param($x,$y) return $x/$y

Is it possible to enforce explicit parameter naming when calling it?

./foo.ps1 5 10 would generate an error
./foo.ps1 -x 5 -y 10 would be OK

Answer:

This code works but it uses something not documented (I could not find anything about negative positions):

Output:

Source:

In powershell, is it possible to enforce naming of arguments? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply