cmdletbinding / compiled ps1

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
yves22
Posts: 5
Last visit: Mon Sep 27, 2021 4:52 am

cmdletbinding / compiled ps1

Post by yves22 »

Hello,

Is there a way to keep the cmdletbinding when you compiled a ps1 script.

get-help [your_script.ps1] -full
can be
your_script.exe /?

I suppose that there is no way, but I hope there is one !

Sincerly yours

User avatar
brittneyr
Site Admin
Posts: 921
Last visit: Fri Dec 03, 2021 12:50 pm
Answers: 21
Been upvoted: 17 times

Re: cmdletbinding / compiled ps1

Post by brittneyr »

When a script is packaged as an executable, it no longer runs as a 'normal' script. You can add a parameter to your package script to show help. All functionality from cmdletbinding can also be handled.
You may find the following helpful:
https://www.sapien.com/blog/2015/11/30/ ... able-file/
https://www.sapien.com/blog/2015/12/07/ ... able-file/
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
yves22
Posts: 5
Last visit: Mon Sep 27, 2021 4:52 am

Re: cmdletbinding / compiled ps1

Post by yves22 »

thanks so much for this usefull and quick answer !!

Best regards,

Locked