Get-GitHubEnvironment¶
SYNOPSIS¶
Retrieves details of a specified GitHub environment or lists all environments for a repository.
SYNTAX¶
Get-GitHubEnvironment [-Owner] <String> [-Repository] <String> [[-Name] <String>] [[-PerPage] <Int32>]
[[-Context] <Object>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
DESCRIPTION¶
This function retrieves details of a specific environment in a GitHub repository when the -Name
parameter
is provided.
Otherwise, it lists all available environments for the specified repository.
Anyone with read access to the repository can use this function.
OAuth app tokens and personal access tokens (classic) need the repo
scope
to use this function with a private repository.
EXAMPLES¶
EXAMPLE 1¶
Get-GitHubEnvironment -Owner 'PSModule' -Repository 'EnvironmentTest' -Name 'test'
Output:
id : 5944178128
node_id : EN_kwDOOJqfM88AAAABYkz10A
name : test
url : https://api.github.com/repos/PSModule/EnvironmentTest/environments/test
html_url : https://github.com/PSModule/EnvironmentTest/deployments/activity_log?environments_filter=test
created_at : 3/16/2025 11:17:52 PM
updated_at : 3/16/2025 11:17:52 PM
can_admins_bypass : True
protection_rules : {@{id=30352888; node_id=GA_kwDOOJqfM84BzyX4; type=required_reviewers; prevent_self_review=False;
reviewers=System.Object[]}, @{id=30352889; node_id=GA_kwDOOJqfM84BzyX5; type=wait_timer; wait_timer=100},
@{id=30352890; node_id=GA_kwDOOJqfM84BzyX6; type=branch_policy}}
deployment_branch_policy : @{protected_branches=False; custom_branch_policies=True}
Retrieves details of the "test" environment in the specified repository.
EXAMPLE 2¶
Get-GitHubEnvironment -Owner 'PSModule' -Repository 'EnvironmentTest'
Output:
id : 5944178128
node_id : EN_kwDOOJqfM88AAAABYkz10A
name : test
url : https://api.github.com/repos/PSModule/EnvironmentTest/environments/test
html_url : https://github.com/PSModule/EnvironmentTest/deployments/activity_log?environments_filter=test
created_at : 3/16/2025 11:17:52 PM
updated_at : 3/16/2025 11:17:52 PM
can_admins_bypass : True
protection_rules : {@{id=30352888; node_id=GA_kwDOOJqfM84BzyX4; type=required_reviewers; prevent_self_review=False;
reviewers=System.Object[]}, @{id=30352889; node_id=GA_kwDOOJqfM84BzyX5; type=wait_timer; wait_timer=100},
@{id=30352890; node_id=GA_kwDOOJqfM84BzyX6; type=branch_policy}}
deployment_branch_policy : @{protected_branches=False; custom_branch_policies=True}
Lists all environments available in the "EnvironmentTest" repository owned by "PSModule".
PARAMETERS¶
-Owner¶
The name of the organization.
Type: String
Parameter Sets: (All)
Aliases: Organization, User
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Repository¶
The name of the Repository.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Name¶
The name of the environment.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: *
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True
-PerPage¶
The maximum number of environments to return per request.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-Context¶
The context to run the command in. Used to get the details for the API call. Can be either a string or a GitHubContext object.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: (Get-GitHubContext)
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
OUTPUTS¶
PSCustomObject¶
NOTES¶
Returns details of a GitHub environment or a list of environments for a repository.
RELATED LINKS¶
https://psmodule.io/GitHub/Functions/Environments/Get-GitHubEnvironment/