Create powershell offline repo
Last updated:
POWERSHELL
Fastest way to install modules on disconnected servers is [[202210111009 Powershell install modules offline|Install powershell modules]].
A better way is to create an offline repo and use it to install the modules.
There are two types of offline repos:
- nuget based
- fileshare based
This will details steps for file share based offline repo.
Install powershellget
- Save OfflinePowerShellGetDeploy
# Save OfflinePowerShellGetDeploy to system which has internet access
Save-Module -Name OfflinePowerShellGetDeploy -Path C:\Users\845874\Downloads\PowerShellGet
Import-Module C:\Users\845874\Downloads\PowerShellGet\OfflinePowerShellGetDeploy
Save-PowerShellGetForOffline -LocalFolder 'C:\Users\845874\Downloads\PowerShellGet\OfflinePowerShellGet'
- Copy this folder to the disconnected system.
- Install OfflinePowerShellGetDeploy
Import-Module .\OfflinePowerShellGetDeploy
# Register a file share on my local machine
$registerPSRepositorySplat = @{
Name = 'LocalPSRepo'
SourceLocation = '\\localhost\PSRepoLocal\'
ScriptSourceLocation = '\\localhost\PSRepoLocal\'
InstallationPolicy = 'Trusted'
}
Register-PSRepository @registerPSRepositorySplat
references:
Working with local PSRepositories - PowerShell | Microsoft Learn