Last active
September 28, 2020 18:27
-
-
Save cdhunt/80984dea7c6e45f42badf6c7f7f7bd8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-PSRepositoryRequirement { | |
param ( | |
[string]$Name, | |
[string]$Uri, | |
[string]$Policy = 'Trusted' | |
) | |
New-RequirementGroup 'Repository' -ScriptBlock { | |
@{ | |
Describe = "$Name is registered" | |
Test = { | |
$repo = Get-PSRepository -Name $Name | |
$repo.SourceLocation -eq $Uri | |
} | |
Set = { | |
Register-PSRepository -Name $Name ` | |
-SourceLocation $Uri ` | |
-PublishLocation $Uri ` | |
-InstallationPolicy $Policy | |
} | |
} | |
}.GetNewClosure() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-PSRepositoryRequirement { | |
param ( | |
[string]$Name, | |
[string]$Uri, | |
[string]$Policy = 'Trusted' | |
) | |
New-RequirementGroup 'Repository' -ScriptBlock { | |
@{ | |
Describe = "$Name is registered" | |
Test = { | |
$repo = Get-PSRepository -Name $Name | |
$repo.SourceLocation -eq $Uri | |
} | |
Set = { | |
Register-PSRepository -Name $Name ` | |
-SourceLocation $Uri ` | |
-PublishLocation $Uri ` | |
-InstallationPolicy $Policy | |
} | |
} | |
} | |
} | |
& {New-PSRepositoryRequirement -Name artifactory -Uri https://url/artifactory/api/nuget/powershell}` | |
| Invoke-Requirement |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment