Closed thisjustin816 closed 1 year ago
I'm using a PAT. This part of the code I posted is passed to the -Credential parameter:
$psCredential = New-Object -TypeName 'System.Management.Automation.PSCredential'
-ArgumentList ( $env:USERNAME, ( ConvertTo-SecureString -String $env:System_AccessToken
-AsPlainText ` -Force ) )
-- Justin Beeson (He/Him) DevOps Engineer @. @.> https://github.com/thisjustin816 https://github.com/thisjustin816 https://www.linkedin.com/in/justinbeeson/ https://www.linkedin.com/in/justinbeeson/
Sent with Shortwave https://www.shortwave.com?utm_medium=email&utm_content=signature&utm_source=amJlZXNvbjgxNkBnbWFpbC5jb20=
On Wed Sep 27, 2023, 10:38 PM GMT, alerickson @.***> wrote:
@thisjustin816 https://github.com/thisjustin816 Thanks for reporting this issue. I'm trying to repro with my own private ADO feed and I noticed that when I use my username + my password as credentials I get a 401, but if I use my username with a PAT it connects successfully. Are you experiencing the same thing? If you haven't tested using a PAT as the password could you try that and let me know if that's successful or not? — Reply to this email directly, view it on GitHub https://github.com/PowerShell/PSResourceGet/issues/1422#issuecomment-1738199449, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJZZKT4ZUZ33SLSZSHWUOQDX4STH3ANCNFSM6AAAAAA5IFA4ZY. You are receiving this because you were mentioned.Message ID: @.***>
And the credential works with Find-PSResource
-- Justin Beeson (He/Him) DevOps Engineer @. @.> https://github.com/thisjustin816 https://github.com/thisjustin816 https://www.linkedin.com/in/justinbeeson/ https://www.linkedin.com/in/justinbeeson/
Sent with Shortwave https://www.shortwave.com?utm_medium=email&utm_content=signature&utm_source=amJlZXNvbjgxNkBnbWFpbC5jb20=
On Wed Sep 27, 2023, 10:46 PM GMT, Justin Beeson @.***> wrote:
I'm using a PAT. This part of the code I posted is passed to the -Credential parameter:
$psCredential = New-Object
-TypeName 'System.Management.Automation.PSCredential'
-ArgumentList ( $env:USERNAME, ( ConvertTo-SecureString-String $env:System_AccessToken
-AsPlainText ` -Force ) )-- Justin Beeson (He/Him) DevOps Engineer @. @.> https://github.com/thisjustin816 https://github.com/thisjustin816 https://www.linkedin.com/in/justinbeeson/ https://www.linkedin.com/in/justinbeeson/
Sent with Shortwave https://www.shortwave.com?utm_medium=email&utm_content=signature&utm_source=amJlZXNvbjgxNkBnbWFpbC5jb20=
On Wed Sep 27, 2023, 10:38 PM GMT, alerickson @.***> wrote:
@thisjustin816 https://github.com/thisjustin816 Thanks for reporting this issue. I'm trying to repro with my own private ADO feed and I noticed that when I use my username + my password as credentials I get a 401, but if I use my username with a PAT it connects successfully. Are you experiencing the same thing? If you haven't tested using a PAT as the password could you try that and let me know if that's successful or not? — Reply to this email directly, view it on GitHub https://github.com/PowerShell/PSResourceGet/issues/1422#issuecomment-1738199449, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJZZKT4ZUZ33SLSZSHWUOQDX4STH3ANCNFSM6AAAAAA5IFA4ZY. You are receiving this because you were mentioned.Message ID: @.***>
@thisjustin816 so sorry, I was looking at a couple different issues, got them mixed up (was hoping I deleted my comment before you got to it). This looks like it may be a piping issue (it's reproing for me when I follow your steps but I can successfully install if I'm not piping into Install). Can you try using Install-PSResource
with the module name and see if that works so we can narrow down the scope?
@thisjustin816 so sorry, I was looking at a couple different issues, got them mixed up (was hoping I deleted my comment before you got to it). This looks like it may be a piping issue (it's reproing for me when I follow your steps but I can successfully install if I'm not piping into Install). Can you try using
Install-PSResource
with the module name and see if that works so we can narrow down the scope?
I get an object reference error if I don't use the pipeline
❯ Install-PSResource @findParams -Scope CurrentUser -Credential $psCredential -Reinstall -PassThru
Install-PSResource: Object reference not set to an instance of an object.
❯ Get-Error
Exception :
Type : System.NullReferenceException
TargetSite :
Name : HttpRequestCallForContent
DeclaringType : Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls,
Microsoft.PowerShell.PSResourceGet, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null
MemberType : Method
Module : Microsoft.PowerShell.PSResourceGet.dll
Message : Object reference not set to an instance of an object.
Source : Microsoft.PowerShell.PSResourceGet
HResult : -2147467261
StackTrace :
at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.HttpRequestCallForContent(String requestUrlV2,
ErrorRecord& errRecord)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.InstallName(String packageName, Boolean
includePrerelease, ErrorRecord& errRecord)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.InstallPackage(VersionType searchVersionType,
NuGetVersion specificVersion, VersionRange versionRange, String pkgNameToInstall, PSRepositoryInfo repository,
ServerApiCall currentServer, ResponseUtil currentResponseUtil, String tempInstallPath, Hashtable packagesHash,
ErrorRecord& errRecord)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.InstallPackages(String[] pkgNamesToInstall,
PSRepositoryInfo repository, ServerApiCall currentServer, ResponseUtil currentResponseUtil, ScopeType scope, Boolean
skipDependencyCheck, FindHelper findHelper)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.ProcessRepositories(String[] repository, Boolean
trustRepository, Boolean skipDependencyCheck, ScopeType scope)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.BeginInstallPackages(String[] names, VersionRange
versionRange, NuGetVersion nugetVersion, VersionType versionType, String versionString, Boolean prerelease, String[]
repository, Boolean acceptLicense, Boolean quiet, Boolean reinstall, Boolean force, Boolean trustRepository, Boolean
noClobber, Boolean asNupkg, Boolean includeXml, Boolean skipDependencyCheck, Boolean authenticodeCheck, Boolean
savePkg, List`1 pathsToInstallPkg, Nullable`1 scope, String tmpPath, HashSet`1 pkgsInstalled)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource.ProcessInstallHelper(String[] pkgNames, String
pkgVersion, Boolean pkgPrerelease, String[] pkgRepository, PSCredential pkgCredential, InstallPkgParams
reqResourceParams)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo : NotSpecified: (:) [Install-PSResource], NullReferenceException
FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
InvocationInfo :
MyCommand : Install-PSResource
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 16
Line : Install-PSResource @findParams -Scope CurrentUser -Credential $psCredential -Reinstall -PassThru
PositionMessage : At line:1 char:1
+ Install-PSResource @findParams -Scope CurrentUser -Credential $psCred …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Install-PSResource
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
@thisjustin816 does it work if you run Install-PSResource -Name $moduleName -Repository $repository -Credential $psCredential
?
Install-PSResource -Name $moduleName -Repository $repository -Credential $psCredential
Same results
❯ $moduleToInstall | Install-PSResource `
> -Scope CurrentUser `
> -Credential $psCredential `
> -Reinstall `
> -PassThru
Install-PSResource: 'Response status code does not indicate success: 404 (Not Found).' Request sent: 'https://pkgs.dev.azure.com/NuvaDev/_packaging/PSSiOPsFeed/nuget/v2/package/PSSiOps/10.1.16'
❯ Install-PSResource -Name $moduleName -Repository $repository -Credential $psCredential
Install-PSResource: Object reference not set to an instance of an object.
❯ get-error
Exception :
Type : System.NullReferenceException
TargetSite :
Name : HttpRequestCallForContent
DeclaringType : Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls,
Microsoft.PowerShell.PSResourceGet, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null
MemberType : Method
Module : Microsoft.PowerShell.PSResourceGet.dll
Message : Object reference not set to an instance of an object.
Source : Microsoft.PowerShell.PSResourceGet
HResult : -2147467261
StackTrace :
at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.HttpRequestCallForContent(String requestUrlV2,
ErrorRecord& errRecord)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.InstallName(String packageName, Boolean
includePrerelease, ErrorRecord& errRecord)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.InstallPackage(VersionType searchVersionType,
NuGetVersion specificVersion, VersionRange versionRange, String pkgNameToInstall, PSRepositoryInfo repository,
ServerApiCall currentServer, ResponseUtil currentResponseUtil, String tempInstallPath, Hashtable packagesHash,
ErrorRecord& errRecord)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.InstallPackages(String[] pkgNamesToInstall,
PSRepositoryInfo repository, ServerApiCall currentServer, ResponseUtil currentResponseUtil, ScopeType scope, Boolean
skipDependencyCheck, FindHelper findHelper)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.ProcessRepositories(String[] repository, Boolean
trustRepository, Boolean skipDependencyCheck, ScopeType scope)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.BeginInstallPackages(String[] names, VersionRange
versionRange, NuGetVersion nugetVersion, VersionType versionType, String versionString, Boolean prerelease, String[]
repository, Boolean acceptLicense, Boolean quiet, Boolean reinstall, Boolean force, Boolean trustRepository, Boolean
noClobber, Boolean asNupkg, Boolean includeXml, Boolean skipDependencyCheck, Boolean authenticodeCheck, Boolean
savePkg, List`1 pathsToInstallPkg, Nullable`1 scope, String tmpPath, HashSet`1 pkgsInstalled)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource.ProcessInstallHelper(String[] pkgNames, String
pkgVersion, Boolean pkgPrerelease, String[] pkgRepository, PSCredential pkgCredential, InstallPkgParams
reqResourceParams)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo : NotSpecified: (:) [Install-PSResource], NullReferenceException
FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
InvocationInfo :
MyCommand : Install-PSResource
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 9
Line : Install-PSResource -Name $moduleName -Repository $repository -Credential $psCredential
PositionMessage : At line:1 char:1
+ Install-PSResource -Name $moduleName -Repository $repository -Credent …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Install-PSResource
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Prerequisites
Steps to reproduce
I have a private PowerShell module feed setup on Azure DevOps that I've been using for years with both legacy PowerShellGet and the beta versions before 3.0.22. When trying to using this new module with my existing *-PSResource functions I'm getting a 404 error when trying to install a module even though
Find-PSResource
can find it. Here's the commands being called:The PSResource repository is registered properly because
$moduleToInstall
has the expected value.Expected behavior
$moduleToInstall
is installed. In my current testing it should be:Actual behavior
Error details
Environment data
Visuals
No response