Author Posts

October 19, 2017 at 10:34 am

I want to register "default" internal PSgallery on all servers for all users to be available, however it seems Register-PSRepository only adds repository for the current user, is there a way to workaround it, preferably without logon scripts running for every user..?

October 19, 2017 at 8:51 pm

You could put your register-psrepository code into a profile.ps1 script on each server in c:\windows\system32\WindowsPowerShell\v1.o, that would run every time anyone ran powershell. You'd want to do something like

if (!(Get-PSRepository YourRepoName -erroraction SilentlyContinue)){
  Register-PSRepository Your RepoName

Just so you don't have a big error message at the start of each session.

Thinking about this got me to wondering where powershell stores that persistent data, since you only have to register a repo once per user. I found PSRepositories.XML in my user folder path: C:\Users\jmmurrah\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet

I tested moving that file over to another user that didn't have any repos and after a session restart it read that file and had the new repo as good as registered. So that's an option as well. Maybe test and see if you can put that in a default profile on a machine and see if new user profiles will pick that up. Might be an option.

October 20, 2017 at 10:44 am

Good ideas, thanks.