Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with new named functions as cmdlet #524

Open
deepjansari-rwe opened this issue May 5, 2024 · 1 comment
Open

Issue with new named functions as cmdlet #524

deepjansari-rwe opened this issue May 5, 2024 · 1 comment

Comments

@deepjansari-rwe
Copy link

deepjansari-rwe commented May 5, 2024

Hi,
I am trying to add function by creating new file in src folder and then installing by install-local.ps1, however the PowerShell module does not identify the new function as cmdlet. I get the message - "The term 'Edit-SafeguardAssetAccountCustom' is not recognized as the name of a cmdlet, function, script file, or operable program."
I can see the new source files with function is placed at C:\Users\xxxxx\Documents\WindowsPowerShell\Modules\safeguard-ps\8.0.99999' after running install-local.ps1

Get-SafeguardCommand also does not list my new function.
However, when I modify existing function (assets.psm1 -> Edit-SafeguardAssetAccount) then it works fine, and module identify modified function with new parameters etc
I always run Remove-Module safeguard-ps and cleanup-local.ps1 before installing new module.

Is there any specific configuration need to be done to register new named functions as powershell cmdlet?

@JeffHarkavy
Copy link
Contributor

@deepjansari-rwe Thank you for contact us, and I apologize for the delayed response.

New functions, aliases, etc. need to be added to the appropriate *ToExport array in safeguard-ps.psd1, for instance if you add a new function Get-MyNewFunctionName to safeguard-ps.psm1

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
    # sslhandling.psm1 is just a helper module -- no functions exported
    # ps-utilities.psm1 is just a helper module -- no functions exported
    # safeguard-ps.psm1
    'Connect-Safeguard','Disconnect-Safeguard','Invoke-SafeguardMethod',
    'Get-SafeguardAccessTokenStatus','Update-SafeguardAccessToken',
    'Get-MyNewFunctionName'
[...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants