diff --git a/src/code/SetPSResourceRepository.cs b/src/code/SetPSResourceRepository.cs index 2ada5bdee..c1a71a05e 100644 --- a/src/code/SetPSResourceRepository.cs +++ b/src/code/SetPSResourceRepository.cs @@ -34,7 +34,7 @@ public sealed class SetPSResourceRepository : PSCmdlet /// /// Specifies the name of the repository to be set. /// - [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ParameterSetName = NameParameterSet)] + [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ParameterSetName = NameParameterSet)] [ArgumentCompleter(typeof(RepositoryNameCompleter))] [ValidateNotNullOrEmpty] public string Name { get; set; } diff --git a/test/SetPSResourceRepository.Tests.ps1 b/test/SetPSResourceRepository.Tests.ps1 index 25eb1c820..d3d15a9a9 100644 --- a/test/SetPSResourceRepository.Tests.ps1 +++ b/test/SetPSResourceRepository.Tests.ps1 @@ -69,6 +69,17 @@ Describe "Test Set-PSResourceRepository" { $res.CredentialInfo | Should -BeNullOrEmpty } + It "set repository given pipeline input ValueFromPipelineByPropertyName passed in" { + Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path + Get-PSResourceRepository -Name $TestRepoName1 | Set-PSResourceRepository -Trusted + $res = Get-PSResourceRepository -Name $TestRepoName1 + $res.Name | Should -Be $TestRepoName1 + $Res.Uri.LocalPath | Should -Contain $tmpDir1Path + $res.Priority | Should -Be 50 + $res.Trusted | Should -Be True + $res.CredentialInfo | Should -BeNullOrEmpty + } + It "set repository given Name and CredentialInfo parameters" { Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path Set-PSResourceRepository -Name $TestRepoName1 -CredentialInfo $credentialInfo1