Automatically setting internal module repository on servers

None of our company servers have internet access, and we want to have any scripts run on them to use and have access only to modules in repositories approved by some IT team. I have implemented both smb and web based nuget module repositories in our lab. It’s easy to execute the command to register the repositories, and then those registrations seem to be persistent every time I log into the server. I’m trying to find out where the repository settings are stored. I’ve been directed to find out if it’s possible to have every person who logs into any server or runs a powershell script on a server, have the corporate approved internal repository for that domain/server automatically be configured without having to run a command. Additionally, I’m very much discouraged from any GPO policy which runs a script at logon. In researching the “register-psrepository” command, it says “Registered repositories are user-specific. They are not registered in a system-wide context.” Is there some way to have the same repository registration exist and be applied consistently? This thought is what makes me ask about a location for the settings which seem to be persistent every time I logon and run powershell, after the first time I execute the registration. Any ideas and suggestions are welcome.

I’m honestly not sure where those values are kept. Gloriously, PowerShellGet is open-source: It’s also written in PowerShell. At at around line 82, it starts to define what looks like XML files to track registered repositories. See if that might give you a nudge in the right direction.

The registrations ARE user-specific, through. I’m pretty sure that’s by design and you’re out going to be able to force it to be systemwide without making changes to the way PowerShellGet works.

I tried procmon to track accesses to files or the registry, but haven’t found anything yet. I’ll start some entire drive greps to see what I can find. In the meantime, I have found a solution which may turn out to be suitable. There are multiple powershell profiles, which are accessed in a specific order. I put the repository settings in the allusers profile, and test for them every time powershell is executed. It’s an easy configuration to manage and then, we can have different repositories for dev, test, and prod.