You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm afraid authenticated feeds (e.g. Azure DevOps artifacts) are a hot mess. I've learned all about PowerShellCompat, SecretManagement and SecretStore, but despite getting all the ducks in a row, I get 401 codes back and storing new package feeds doesn't store the auth creds etc. No-one believes me, but if you use an authenticated feed for a couple of weeks, you'll get the picture.
Here is how I try to set things up on a new machine:
Write-Host "Update PowerShellGet v2..."
Install-Module PowerShellGet -Repository PSGallery -AllowClobber -Force
Write-Host "Install PowerShellGet 3.0.14-beta14 because things got a little worse in a later version..."
Install-Module -Name PowerShellGet -RequiredVersion 3.0.14-beta14 -AllowPrerelease -Force
Write-Host "Install CompatPowerShellGet in case a module tries to use PowerShellGet v2 commands internally..."
Install-PSResource -Name CompatPowerShellGet -Repository PSGallery -TrustRepository
Write-Host "Install secret management modules..."
Install-PSResource -Name Microsoft.PowerShell.SecretManagement -Repository PSGallery -TrustRepository
Install-PSResource -Name Microsoft.PowerShell.SecretStore -Repository PSGallery -TrustRepository
Import-Module Microsoft.PowerShell.SecretStore
# Write-Host "Configure local SecretStore with password so no prompts are shown while running in pipeline..."
# Set-SecretStoreConfiguration -Scope CurrentUser -Authentication None -Interaction None -Confirm:$false -Verbose
Write-Host "Create new default secret vault for dependent modules to use..."
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
Write-Host "If OneDrive is installed, it's stolen your modules. So you need to mark 'C:\Users\neil.barnwell\OneDrive - bybox.com\Documents\PowerShell' as 'Always keep on this device', and then ensure you duplicate it's contents to C:\Users\neil.barnwell\Documents\PowerShell' because some things look there directly rather than using env variables to obtain the path to the profile folder"
Write-Host "Register private artifacts feed as PS module repository (v2 feed as v3 isn't supported)..."
$feedUrl = "https://[companyname].pkgs.visualstudio.com/DevOps/_packaging/[artifacts feed name]/nuget/v2"
$credentials = Get-Credential -Message "Enter Azure Devops email and PAT"
$credentialInfo = New-Object Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo ("SecretStore", "PowerShellModulePAT")
Set-Secret -Name "PowerShellModulePAT" -Secret $credentials
Register-PSResourceRepository -Name [artifacts feed name] -Uri $feedUrl -CredentialInfo $credentialInfo -Trusted
After this I should be able to do Install-PSResource [package id] but as I said, I get a lot of errors and failures.
I've currently given up, and instead I'm just automating the clone of my PowerShell module git repos, and copying the module files into my profile's PowerShell\modules folder. :(
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm afraid authenticated feeds (e.g. Azure DevOps artifacts) are a hot mess. I've learned all about PowerShellCompat, SecretManagement and SecretStore, but despite getting all the ducks in a row, I get 401 codes back and storing new package feeds doesn't store the auth creds etc. No-one believes me, but if you use an authenticated feed for a couple of weeks, you'll get the picture.
Here is how I try to set things up on a new machine:
After this I should be able to do
Install-PSResource [package id]
but as I said, I get a lot of errors and failures.I've currently given up, and instead I'm just automating the clone of my PowerShell module git repos, and copying the module files into my profile's
PowerShell\modules
folder. :(Beta Was this translation helpful? Give feedback.
All reactions