至于这个……
这些是私人脚本,不想像这样发布
.. 然后在 prem repo 上构建你自己的。
如何做到这一点由微软和其他公司完整记录,如下所示:
Setting up an Internal PowerShellGet Repository
Powershell: Your first internal PSScript repository
# Network share
# The other thing we should have is an empty folder on a network share. This will be the location of our repository. Your users will need to have access to this location if they are going to be loading content from it.
$Path = '\\Server\Share\MyRepository'
# If you just want to experiment with these commands, you can use a local folder for your repository. PowerShellGet does not care where the folder lives.
# Creating the repository
# The first thing we should do is tell PowerShellGet that our $Path is a script repository.
Import-Module PowerShellGet
$repo = @{
Name = 'MyRepository'
SourceLocation = $Path
PublishLocation = $Path
InstallationPolicy = 'Trusted'
}
Register-PSRepository @repo
# And we are done.
Get-PSRepository
Name InstallationPolicy SourceLocation
---- ------------------ --------------
MyRepository Trusted \\Server\Share\MyRepository
PSGallery Untrusted https://www.powershellgallery.com/api/v2/
# Other than creating a folder, there is no complicated setup to creating this repository. Just by telling PowerShellGet that the folder is a repository, it will consider it to be one. The one catch is that you need to run this command on each machine to register the repository.
或者建立你自己的内部 git 服务器。
Bonobo Git Server for Windows 是一个 Web 应用程序,您可以
安装在您的 IIS 上。它提供了一个简单的管理工具和访问
在您的服务器上自托管的 git 存储库。
https://bonobogitserver.com/features
https://bonobogitserver.com/install
OP 更新
至于你的后续:
一旦我在他们的本地计算机中获得了文件,如何将它带来
进入他们当前的 powershell 会话?
请记住,Import-Module 是关于要加载的已在本地计算机上的模块,而不是来自任何本地或远程 repo 的模块。您仍然必须安装模块形式,无论您的目标是什么。
如果您的模块已正确定义并安装在本地计算机上,如果您使用的是 PowerShell v3 或更高版本,则不需要 Import-Module,因为如果设计和实施得当,它们应该会自动加载。
具体来说,您的后续问题与此Q&A 重复
如何从本地文件夹安装/更新 PowerShell 模块 - 设置内部模块存储库
您应该只需要执行正常步骤即可从您的存储库中获取和使用该模块。
Find-Module -Name 'MyModule' -Repository MyRepository |
Save-Module -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Modules"
Install-Module -Name 'MyModule'
Import-Module -Name 'MyModule'
另见:
Update-Module