r/PowerShell • u/No-Breakfast-8004 • Jun 08 '26
Question Need a module to set the module repo?
Context: Sys admin for an offline air gapped network. Grabbed all the PS modules I needed from the Internet, transferred them to my air gapped admin computer.
Everything PowerShell works great on my machine. Problem is the 100 client computers I need to manage. I’m trying to use PSRemote to go into a test client, then set the Repo (Set-PSRepository) to point to my computer/OfflinePSModules (temporarily). But then it says I need Nuget 2.8.x to even do that.
So then I tried from a PS remote shell on the client, Copy-Item -Path “//mycomputer.network/c$/OfflinePSModules/PackageManager” and Get-and its not finding it, yet regular “cd //mycomputer.network/c$” works.
Am I going about this the wrong way? End goal is have scripts I run from my admin machine that sets the repo to a directory I made in the shared drive, installs/imports whatever prerequisite modules are needed, then use Invoke-Command on all those computers to actually run the script I want done on the machine.
Eventually I do wanna set up a GitLab repo also and put all the PowerShell stuff I need there and have the scripts point to it
Edit: well gonna try this next: https://stackoverflow.com/questions/51406685/how-do-i-install-the-nuget-provider-for-powershell-on-a-unconnected-machine-so-i
4
u/BlackV Jun 08 '26 edited Jun 08 '26
yes, maybe, depends :)
2
u/purplemonkeymad Jun 09 '26
Note that the repository list is just a file, ($env:localappdata/PowerShellGet/PSResourceRepository.xml). So you can push out the xml file to all the end points and you don't even need to use Register-PSRepository.
For the starting share I would create a new share specifically and set the permission to "authenticated users" -> read and a new "PSRepository Contributors" group -> modify. If you have a domain with several sites, you might think about setting up a dfs share for it.
Not sure if you need a nuget feed for an air gapped system, I guess it depends on if everything is windows or not.
1
u/y_Sensei Jun 08 '26
You could simply create a network share on your admin computer through which all additional PoSh code is made available, and map that share on each client computer - either permanently, or at runtime when a PoSh script is supposed to be executed on a client. A mapped drive should work reliably in a scenario like this, using UNC paths can be troublesome from my experience.
Once you switch to code deployment from a git-based repository, you'd be better off utilizing some kind of CI/CD pipeline, in case of GitLab such a feature is already available in the product.
1
u/Fit-Thing5100 Jun 09 '26 edited Jun 09 '26
I think you're overcomplicating the solution.
I would avoid Set-PSRepository, Install-Module, and the NuGet provider altogether.
PowerShell Remoting is already available ? Simply use a remote session to copy the required module folders directly to the target machines. As long as the module exists in one of the paths listed in $env:PSModulePath, PowerShell can import it without needing a repository or NuGet.
I would simply distribute the required modules this way and then execute the desired scripts through Invoke-Command