Repository navigation
Expand file tree
/
Copy pathSet-PSMDStagingRepository.ps1
More file actions
54 lines (47 loc) · 1.74 KB
/
Copy pathSet-PSMDStagingRepository.ps1
File metadata and controls
54 lines (47 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function Set-PSMDStagingRepository
{
<#
.SYNOPSIS
Define the repository to use for deploying modules along with scripts.
.DESCRIPTION
Define the repository to use for deploying modules along with scripts.
By default, modules are deployed using the PSGallery, which may be problematic:
- Offline computers do not have access to it
- Low performance compared to a local mirror
.PARAMETER Path
The local path to use. Will configure that path as a PSRepository.
The new repository will be named "PSMDStaging".
.PARAMETER Repository
The name of an existing repository to use
.EXAMPLE
PS C:\> Set-PSMDStagingRepository -Path 'C:\PowerShell\StagingRepo'
Registers the local path 'C:\PowerShell\StagingRepo' as a repository and will use it for deploying modules along with scripts.
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, ParameterSetName = 'Path')]
[PsfValidateScript('PSModuleDevelopment.Validate.Path', ErrorString = 'PSModuleDevelopment.Validate.Path')]
[string]
$Path,
[Parameter(Mandatory = $true, ParameterSetName = 'Repository')]
[string]
$Repository
)
process
{
if ($Path)
{
if (Get-PSRepository -Name PSMDStaging -ErrorAction Ignore)
{
Unregister-PSRepository -Name PSMDStaging
}
Register-PSRepository -Name PSMDStaging -SourceLocation $Path -PublishLocation $Path -InstallationPolicy Trusted
Set-PSFConfig -Module PSModuleDevelopment -Name 'Script.StagingRepository' -Value PSMDStaging -PassThru | Register-PSFConfig
}
else
{
Set-PSFConfig -Module PSModuleDevelopment -Name 'Script.StagingRepository' -Value $Repository -PassThru | Register-PSFConfig
}
}
}