Register-PSRepository for all users

This topic contains 2 replies, has 2 voices, and was last updated by  Aurimas N. 7 months ago.

  • Author
  • #82457

    Aurimas N.

    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..?

  • #82562

    Jeremy Murrah

    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.

  • #82609

    Aurimas N.

    Good ideas, thanks.

You must be logged in to reply to this topic.