get-psrepository

Good day,

Recently we have been working to move our Powershell modules and script to source control. We have setup a repository per module in azure devops and created a pipeline which when pull request is merged to master it does basic testing. Can module import, does it have manifest and pester de-linting. After all this it then does a nuget package and push to nuget feed.

My user account created the feed and i am listed as owner.

I attempted to register-psrepository however it continually fails unless i add credential parameter (get-credential).

My questions are is it possible to automate this so if others in my group open a powershell session if will connect to the feed and allow them to import-module directly from the feed?

 

I have been looking at articles on the web but feel like i am doing something wrong.

 

Any help would be appreciated. Thank you

Jason

Hi Jason,

If you understood you correctly, the method below will be helpful…

# Save the credentials - One time and interactive 
$UserName = 'UserName'
$PlainPassword = 'PlainText'
$FileShare = '\\Server\Share\GalleryCredential.xml'
$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword
$Credential | Export-Clixml -Path $FileShare

# Add this piece of code in the user profiles or in the automation script
$FileShare = '\\Server\Share\GalleryCredential.xml'
$Credential = Import-Clixml -Path $FileShare
$PSDefaultParameterValues = @{"*-Module:Credential"=$Credential}

Thank you.

Thank you for the help.

I Appreciate it.