0

The cmdlet script I have written is working well. I want to use it when I am in any directory. I can do this by putting it in a directory on the PATH.

However, that is not really "installed" as a cmdlet. It always has the ".ps1" extension on the command name.

Must a module be written and installed?

The bigger issue is that everyone in my group should be able to use the script. Does that mean sourcing it into the All Users, All Hosts profile script? User's should run PowerShell using -NoProfile for production processes. If a .psm1 is created, will PowerShell always load it?

0

Turn your cmdlet into a PowerShell module and then place it into the common location for server-wide PowerShell modules. Even when using -noprofile your cmdlet will be available for all users.

There are many resources on how to create PowerShell modules online, it's a different question.

1

When I was faced with a similar problem, I rewrote the script to be a Function that used cmdlet binding. Then I put the function definition in my $PROFILE so that it's always available to me.

Depending on what you are really trying to do, this may work for you.

  • Thanks for your answer. A module looks like the best way to go. And, since PS 3.0, it does not need any mention in any of the profile scripts. – lit Jul 9 '17 at 22:21

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.