Former-commit-id: 33588f77aeaf8a7d0f5a633ae592d7a3630bb76c
This commit is contained in:
Renan Vilas Novas 2021-07-19 20:55:43 -03:00
Родитель 1d0ad23146
Коммит d55fa41c43
1 изменённых файлов: 17 добавлений и 7 удалений

Просмотреть файл

@ -1,24 +1,34 @@
param (
# Azure DevOps organization where you want to create this HOL resources
[parameter(mandatory=$true)]
[string]$projectAlias = '<projectAlias>'
[string]$projectName = '<projectName>',
# Simple alias for the project (less than 8 characters)
[parameter(mandatory=$true)]
[string]$projectAlias = '<projectAlias>',
)
$filter = ("rg-" + $projectAlias + "-")
$myResources = Get-AzResourceGroup | ? ResourceGroupName -match $filter | Select-Object ResourceGroupName
$myServicePrincipals = Get-AzADServicePrincipal -DisplayName ("SP-"+$projectName+"-DevTest") | Select-Object DisplayName
Write-Host "`nService Principal`n-----------------"
$myServicePrincipals | ForEach-Object {
Write-Host $_.DisplayName
}
Write-Host "`nResourceGroupName`n-----------------"
$myResources | ForEach-Object {
$myResourceGroups = Get-AzResourceGroup | ? ResourceGroupName -match $filter | Select-Object ResourceGroupName
Write-Host "`nResource Group`n-----------------"
$myResourceGroups | ForEach-Object {
Write-Host $_.ResourceGroupName
}
$answer = read-host -prompt "Found missing roles. Press 'y' to delete them."
$answer = read-host -prompt "`nPress 'y' to delete all the resources listed above."
$yesList = 'yes','y'
if ($yesList -contains $answer.ToLower()) {
Write-Host $answer
Get-AzResourceGroup | ? ResourceGroupName -match $filter | Remove-AzResourceGroup -AsJob -Force
Get-AzADServicePrincipal -DisplayName ("SP-"+$projectName+"-DevTest") | Remove-AzADServicePrincipal -Force
} else {
Write-Host "Your resources were not deleted. "
Write-Host "[Command Skipped] Your resources were not deleted."
}