Last active
July 17, 2023 18:27
-
-
Save andrewmatveychuk/54bedbf5e891a8318a7f2eb765ddab16 to your computer and use it in GitHub Desktop.
Using Register-PackageSource to register a PowerShell repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$patToken = $env:SYSTEM_ACCESSTOKEN | ConvertTo-SecureString -AsPlainText -Force | |
$credential = New-Object System.Management.Automation.PSCredential($env:SYSTEM_ACCESSTOKEN, $patToken) | |
Register-PackageSource -ProviderName 'PowerShellGet' -Name <YOUR_REPOSITORY_NAME> -Location <REPOSITORY_LOCATION> -Credential $Credentials | |
Find-Module -Name 'YOUR_MODULE_NAME' -Credential $credential | |
Install-Module -Name 'YOUR_MODULE_NAME' -Credential $credential |
@Brilbroeder It depends on where your feed is hosted. If you use Azure DevOps Artifacts, then you should generate your access token: https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows
Here is the extract from my PSDepend definition:
And here is the Enter-Build section from the InvokeBuild script I use to build the module:
And, finally, here is how it is being invoked in the pipeline:
That's cool stuff.. i'm also using PSDepend & InvokeBuild but I never thought of using it like you did. GREAT Example.!! πβ¨π
Hey @ckolumbus,
Thanks for the feedback! π»
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like to do this download on my local machine. What to use as credentials ?