microsoft/PowerShellForGitHub
View on GitHubExported functions not behaving correctly with -ErrorAction SilentlyContinue
Open
#409 opened on Jun 26, 2023
buggood first issuehelp wanted
Repository metrics
- Stars
- (635 stars)
- PR merge metrics
- (PR metrics pending)
Description
Issue Details
Get-GitHubTeam -TeamName foo -ErrorAction SilentlyContinue returns all teams when team foo doesn't exist.
Steps to reproduce the issue
In the below example, I want to provision BTeam. I first check to see if that team exists so that I can create it if not. Instead, I end up modifying the settings for ATeam.
$Org = 'MyOrg'
New-GitHubTeam -Org $Org -TeamName ATeam
$team = Get-GitHubTeam -Org $Org -TeamName BTeam -ErrorAction SilentlyContinue
if($null -eq $team){
New-GitHubTeam -Org $Org -TeamName BTeam
} else {
Set-GitHubTeam -Org $Org -TeamName BTeam
}
Verbose logs showing the problem
N/A
Suggested solution to the issue
Immediately exit function Get-GitHubTeam when -TeamName is specified but no match is found.
Add a return at line 193.
Requested Assignment
- If possible, I would like to fix this.
Operating System
OsName : Microsoft Windows 10 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage : en-US
OsMuiLanguages : {en-US}
PowerShell Version
Name Value
---- -----
PSVersion 7.3.4
PSEdition Core
GitCommitId 7.3.4
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Module Version
Running: 0.16.1
Installed: 0.16.1