Public/Remove-GHRepo.ps1
function Remove-GHRepo { <# .Synopsis Removes a repository .Description Deleting a repository requires admin access. The delete_repo scope is required. .Example Remove-GHRepo user reponame .Example Remove-GHRepo user reponame -Confirm #> param( [Parameter(Mandatory)] $owner, [Parameter(Mandatory)] $reponame, $AccessToken, [Switch]$Confirm ) if (!$Confirm) { $message = "This will delete repo $($owner)/$($reponame) - type Y to confirm" $result = Read-Host $message if($result -match "[nN]" -or [string]::IsNullOrEmpty($result)) { return } } if (Test-GHRepo $owner $reponame -AccessToken $AccessToken) { $url = 'https://api.github.com/repos/{0}/{1}' -f $owner, $reponame $result = Invoke-GitHubAPI -Uri $url -Method Delete -AccessToken $AccessToken Write-ToConsole * INFO "Removed $owner/$reponame" } else { Write-ToConsole * INFO "Nothing to remove - $owner/$reponame not found" } } |