diff --git a/examples/GitHubOutput.ps1 b/examples/Actions/GitHubOutput.ps1 similarity index 100% rename from examples/GitHubOutput.ps1 rename to examples/Actions/GitHubOutput.ps1 diff --git a/examples/AppManagement.ps1 b/examples/Apps/AppManagement.ps1 similarity index 100% rename from examples/AppManagement.ps1 rename to examples/Apps/AppManagement.ps1 diff --git a/examples/Apps/EnterpriseApps.ps1 b/examples/Apps/EnterpriseApps.ps1 new file mode 100644 index 000000000..c41e8b007 --- /dev/null +++ b/examples/Apps/EnterpriseApps.ps1 @@ -0,0 +1,48 @@ +$appIDs = @( + 'qweqweqwe', + 'qweqweqweqwe' +) + +$organization = '*' +filter Install-GithubApp { + param( + [Parameter()] + [string] $Enterprise = 'msx', + + [Parameter()] + [string] $Organization = '*', + + [Parameter( + Mandatory, + ValueFromPipeline + )] + [string] $AppID + ) + + begin { + + } + + process { + $installableOrgs = Get-GitHubEnterpriseInstallableOrganization -Enterprise $Enterprise -Debug -Verbose + $orgs = $installableOrgs | Where-Object { $_.login -like $organization } + foreach ($org in $orgs) { + foreach ($appIDitem in $AppID) { + Install-GitHubAppOnEnterpriseOrganization -Enterprise $Enterprise -Organization $org.login -ClientID $appIDitem -RepositorySelection all | ForEach-Object { + [PSCustomObject]@{ + Organization = $org.login + AppID = $appIDitem + } + } + } + } + } + + end { + + } +} + +$appIDs | Install-GithubApp -Organization $organization -Debug -Verbose + +$installation = Get-GitHubAppInstallation diff --git a/examples/Apps/Get-WebhookDelivery.ps1 b/examples/Apps/Get-WebhookDelivery.ps1 new file mode 100644 index 000000000..b1363790d --- /dev/null +++ b/examples/Apps/Get-WebhookDelivery.ps1 @@ -0,0 +1,33 @@ +Connect-GitHub -ClientID $ClientID -PrivateKey $PrivateKey -HostName 'msx.ghe.com' + +$deliveries = Get-GitHubAppWebhookDelivery | ForEach-Object { + [pscustomobject]@{ + Success = ($_.status_code -lt 300) -and ($_.status_code -ge 200) + StatusCode = $_.status_code + Status = $_.status + ID = $_.id + GUID = $_.guid + Date = $_.delivered_at + Duration = $_.duration + Redelivery = $_.redelivery + Event = $_.event + Action = $_.action + InstallationID = $_.installation.id + RepositoryID = $_.repository.id + URL = $_.url + ThrottledAt = $_.throttled_at + } +} + +$deliveries | Where-Object { $_.Event -eq 'team' } | Format-Table -AutoSize + + + + +$Return.Response | Format-Table -AutoSize + +Set-GitHubDefaultContext -Context 'msx.ghe.com/Marius-Storhaug' + +1..10 | ForEach-Object { + New-GitHubTeam -Organization 'my-org' -Name "Test$_" +} diff --git a/examples/Teams/Get-AllTeams.ps1 b/examples/Teams/Get-AllTeams.ps1 new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/examples/Teams/Get-AllTeams.ps1 @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/Teams/Teams.ps1 b/examples/Teams/Teams.ps1 new file mode 100644 index 000000000..a5f3f7e1d --- /dev/null +++ b/examples/Teams/Teams.ps1 @@ -0,0 +1,39 @@ +$filter = 'my-org' + +$allOrgs = Get-GitHubOrganization $filter -Verbose +$orgs = $allOrgs | Where-Object { $_.login -like $filter } + +$orgs | Select-Object login, id, disk_usage +foreach ($org in $orgs) { + 1..100 | ForEach-Object { + New-GitHubTeam -Organization $org.login -Name "Team$_" -Description "Team $_" -Verbose + } +} + + +$Teams = Get-GitHubTeamListByOrg -Organization $filter | ForEach-Object { + [pscustomobject]@{ + Organization = $filter + Name = $_.name + Id = $_.id + } +} + + +$orgs = Get-GitHubOrganization +$teams = $orgs | ForEach-Object { + $org = $_.login + Get-GitHubTeamListByOrg -Organization $org | ForEach-Object { + [pscustomobject]@{ + Organization = $org + Team = $_.name + TeamId = $_.id + } + } +} +$teams + + +$Teams | Where-Object { $_.Name -like 'Team*' } | ForEach-Object { + Remove-GitHubTeam -Organization $_.Organization -Name $_.Name -Verbose +}