Product: PowerShell Studio 2019 (64 Bit)
Build: v5.6.160
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.16299.0
When compiling a Script to an executable i want to use the Powershell build-in Help function.
My Workaround is in the code below.
Basically i recreate the Script (MyScript.ps1 -> MyScript.exe) Help including Parameter definition into a dummy function (MyScript) so i can print out the help via 'Get-Help -Detailed MyScript' (Where MyScript only shows the duplicated Help from the function.) from inside the compiled script.
The output is correct but i have to copy the Metadata for help creation from the Script to the Function on every change.
Is there an easier way to get Help for a compiled exe in a single file sfolution?
Code: Select all
[CmdletBinding(DefaultParameterSetName = 'help',
SupportsShouldProcess = $true)]
...
# Functions
function myScript{
<#
.SYNOPSIS
MySynopsis
...
#>
#param definition
...
}
..
#**********************************************
#region Parameter Handling
#----------------------------------------------
# Write Parameters into Variables
$PSBoundParameters.GetEnumerator() | ForEach-Object {
$PName = $_.Key
$PValue = $_.Value
if (($PValue.length -le 0) -or ($PValue -eq $False)) {
$PValue = $true
}
Write-Host "Parameter: $PName : $PValue" -ForegroundColor green
$PR = Set-Variable -Name $PName -Value $PValue -Scope global
}
#----------------------------------------------
#endregion Parameter Handling
#**********************************************
...
if ($help.IsPresent -or ($PsCmdlet.ParameterSetName -eq 'Help')) {
Get-Help -Detailed MyScript
return
}
PS: Searching for the String "Help" in the forums is impossible since it is an ignored string!