-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitialize-PowerShellGalleryConfig.ps1
More file actions
60 lines (49 loc) · 2 KB
/
Initialize-PowerShellGalleryConfig.ps1
File metadata and controls
60 lines (49 loc) · 2 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
55
56
57
58
59
60
function Initialize-PowerShellGalleryConfig {
<#
.SYNOPSIS
Initialize the PowerShellGallery module configuration.
.DESCRIPTION
Initialize the PowerShellGallery module configuration.
.EXAMPLE
Initialize-PowerShellGalleryConfig
Initializes the PowerShellGallery module configuration.
.EXAMPLE
Initialize-PowerShellGalleryConfig -Force
Forces the initialization of the PowerShellGallery module configuration.
#>
[OutputType([void])]
[CmdletBinding()]
param (
# Force the initialization of the PowerShellGallery config.
[switch] $Force
)
begin {
Write-Debug '[Initialize-PowerShellGalleryConfig] - Start'
}
process {
Write-Debug "Force: [$Force]"
if ($Force) {
Write-Debug 'Forcing initialization of PowerShellGalleryConfig.'
$config = Set-Context -Context $script:PowerShellGallery.DefaultConfig -Vault $script:PowerShellGallery.ContextVault -PassThru
$script:PowerShellGallery.Config = $config
return
}
if ($null -ne $script:PowerShellGallery.Config) {
Write-Debug 'PowerShellGalleryConfig already initialized and available in memory.'
return
}
Write-Debug 'Attempt to load the stored PowerShellGalleryConfig from ContextVault'
$config = Get-Context -ID $script:PowerShellGallery.DefaultConfig.ID -Vault $script:PowerShellGallery.ContextVault
if ($config) {
Write-Debug 'PowerShellGalleryConfig loaded into memory.'
$script:PowerShellGallery.Config = $config
return
}
Write-Debug 'Initializing PowerShellGalleryConfig from defaults'
$config = Set-Context -Context $script:PowerShellGallery.DefaultConfig -Vault $script:PowerShellGallery.ContextVault -PassThru
$script:PowerShellGallery.Config = $config
}
end {
Write-Debug '[Initialize-PowerShellGalleryConfig] - End'
}
}