Powershell: Cmdlets not recognized after successful Install-Module on Github Actions

Created on 9 Jan 2020  ·  12Comments  ·  Source: PowerShell/PowerShell

Steps to reproduce

Install-Module -Name CredentialManager -AcceptLicense -AllowClobber -Force -Verbose -Scope CurrentUser
Get-StoredCredential

Expected behavior

I successfully installed the CredentialManager package using the install-module command, but I was unable to execute the Cmdlets in the package

Actual behavior

Install-Module -Name CredentialManager -AcceptLicense -AllowClobber -Force -Verbose -Scope CurrentUser
2020-01-09T09:16:46.5626286Z VERBOSE: Module 'CredentialManager' was installed successfully to path 'C:\Users\runneradmin\Documents\PowerShell\Modules\CredentialManager\2.0'.

```none
Get-StoredCredential
2020-01-09T09:16:47.5886008Z Get-StoredCredential : The term 'Get-StoredCredential' is not recognized as the name of a cmdlet, function, script file, or operable program.
2020-01-09T09:16:47.5886476Z Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


# Environment data

<!-- provide the output of $PSVersionTable -->

```none
Name                           Value
----                           -----
PSVersion                      6.2.3
PSEdition                      Core
GitCommitId                    6.2.3
OS                             Microsoft Windows 10.0.17763 
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

This issue appears in the windows-latest environment of Github Actions and does not exist on my own machine

Issue-Question Resolution-Answered Resolution-External

Most helpful comment

Hi @zhanghongtong
Perhaps this is an issue of the module, not a PowerShell.

https://www.powershellgallery.com/packages/CredentialManager/2.0/Content/CredentialManager.psd1

You can see the use of wildcards for FunctionsToExport and CmdletsToExport in the module manifest. This is not correct usage and often breaks autoloading for modules.
If possible, you have to contact the module author to request a fix.

The workaround is to import the module explicitly after installing it.

Install-Module -Name CredentialManager -AcceptLicense -AllowClobber -Force -Verbose -Scope CurrentUser
Import-Module -Name CredentialManager
Get-StoredCredential

All 12 comments

Hi @zhanghongtong
Perhaps this is an issue of the module, not a PowerShell.

https://www.powershellgallery.com/packages/CredentialManager/2.0/Content/CredentialManager.psd1

You can see the use of wildcards for FunctionsToExport and CmdletsToExport in the module manifest. This is not correct usage and often breaks autoloading for modules.
If possible, you have to contact the module author to request a fix.

The workaround is to import the module explicitly after installing it.

Install-Module -Name CredentialManager -AcceptLicense -AllowClobber -Force -Verbose -Scope CurrentUser
Import-Module -Name CredentialManager
Get-StoredCredential

Hi @mkht
Thanks for your reply .
After installing the module, I tried to use Get-Command *-StoredCredential to query the cmdlet, but I didn't find it. It can be used normally on my own machine. Is there any special setting for GitHub actions?
Or is there another way to configure credentials to access Github in PowerShell? I can set it in the GUI, but I don't know how to set it in PowerShell.

This issue has been reproduced on my local machine, so I don't think it's specific to GitHub Actions.
I don't know why it doesn't reproduce on your machine. sorry.

Get-Command * -StoredCredential returns no results because the module was not loaded correctly.

Again, use Import-Module to explicitly import modules. That is a workaround.

PowerShell 6.2.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS C:\Program Files\PowerShell\6> Install-Module -Name CredentialManager -AcceptLicense -AllowClobber -Force -Scope CurrentUser
PS C:\Program Files\PowerShell\6> Get-Command *-StoredCredential
PS C:\Program Files\PowerShell\6> Get-StoredCredential
Get-StoredCredential : The term 'Get-StoredCredential' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-StoredCredential
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Get-StoredCredential:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

PS C:\Program Files\PowerShell\6> Import-Module -Name CredentialManager
PS C:\Program Files\PowerShell\6> Get-Command *-StoredCredential

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-StoredCredential                               2.0        CredentialManager
Cmdlet          New-StoredCredential                               2.0        CredentialManager
Cmdlet          Remove-StoredCredential                            2.0        CredentialManager

PS C:\Program Files\PowerShell\6> Get-StoredCredential
UserName                                Password
--------                                --------
PersonalAccessToken System.Security.SecureString

Hi @mkht
I just retried it and it worked. Thank you.
But I have a new problem

New-StoredCredential : Argument 'New-StoredCredential' is not recognized as a cmdlet: Could not load type 'System.Web.Security.Membership' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Maybe this isn't powershell's problem, but if you know what to do, please let me know, thanks again.

@zhanghongtong
The error message indicates that the command cannot be executed because the System.Web.Security.Membership class cannot be found.

Unfortunately, the System.Web.Security.Membership class cannot be used because it is not implemented in .NET Core, which is based on PowerShell Core.
The CredentialManager module you are using is not compatible with PowerShell Core. You'll need to ask the module author for help or consider an alternative.

@mkht Thanks for your reply .
Do you have any ideas for configuring credentials to access github in powershell?
Thanks again.

I want to access my private repositories on github through powershell because I need to pull them when I build projects, but I don't want to enter passwords manually because github ations don't have a GUI interface.

库里面没几个core可以用的,linux mac 更是什么都没有。这个东西连平台和系统版本,软件版本都没有区分。下载下来的东西全都不能用。我都不知道怎么过滤。

find-module PSreadline不会找到关于系统版本和适用范围的任何信息

@zhanghongtong
You can use encrypted secrets to handle sensitive information in your GitHub Actions workflow.
Save the token for accessing the private repository in a secret and assign it to a variable in the PowerShell script to handle it.

It is off topic of this issue and will not be described in detail. See GitHub Actions help.
https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets

Encrypted secrets allow you to store sensitive information, such as access tokens, in your repository.

This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes.

On PowerShell 5.x.x "CredentialManager" works perfect but on PowerShell 7.x.x (I have 7.0.3) only partialy... "Get-StoredCredential" command works but "New-StoredCredential" powershell recognize but without any of arguments - so if I press "TAB" I can not see any of arguments like "-Target"...

Do any one had that kind of issue???

PS
I also tried with latest version of PowerShell RC)

If we use just a command "New-StoredCredential" we will have:
"New-StoredCredential: Argument 'New-StoredCredential' is not recognized as a cmdlet: Could not load type 'System.Web.Security.Membership' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'."

I had found that probably in Powershell Core module "CredentialManager" is not supported: "Since PowerShell Core is built on .NET Core it wont be possible to use classes from System.Web.dll in PowerShell Core."

So prabably "CredentialManager" module will fully works only on "Desktop" version of Powershell (not "Core")

Was this page helpful?
0 / 5 - 0 ratings