Question:
Usually powershell script files end with .ps1, and modules end with .psm1.
Can one have powershell scripts/modules in files with no extension? Just “build” or “start” and so on? Will this cause an issue in any specific environment?
If yes, Can one have powershell scripts/modules in files with other “texty” extensions like .sh, .ps etc?
Is there an easier way to invoke powershell scripts instead of keying in .\script.ps1 arg1, arg2 , for example like : go arg1, arg2?
Answer:
No, you can’t. The error message for Import-Module
is pretty clear:
1 2 3 |
Import-Module : The extension '.xyz' is not a valid module extension. The supported module extensions are '.dll', '.ps1', '.psm1', '.psd1', '.cdxml' and '.xaml'. Correct the extension then try adding the file |
And if you try to call a script with a non-standard extension, Windows will simply pop the “What program would you like to open this with?” dialog. If you choose to open with Powershell, a new Powershell process will be spawned, which will just do the same thing.
If you try to assign a new extension, like .xyz
to always be opened with Powershell, you will end up with an never-ending series of Powershell processes being spawned, each attempting in vain to open the file with a new instance of Powershell. I just tried it 🙂