Functions/Public/identity/Remove-vRATenant.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function Remove-vRATenant {
<#
    .SYNOPSIS
    Remove a vRA Tenant
    
    .DESCRIPTION
    Remove a vRA Tenant
    
    .PARAMETER Id
    Tenant ID

    .INPUTS
    System.String.

    .OUTPUTS
    None

    .EXAMPLE
    Remove-vRATenant -Id Tenant02
    
    .EXAMPLE
    Get-vRATenant -Id Tenant02 | Remove-vRATenant -Confirm:$false
#>

[CmdletBinding(SupportsShouldProcess,ConfirmImpact="High")]

    Param (

    [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
    [ValidateNotNullOrEmpty()]
    [String[]]$Id
    )    

    begin {
    
    }
    
    process {    
            
        foreach ($TenantId in $Id){
                
            try {
                if ($PSCmdlet.ShouldProcess($Id)){

                    $URI = "/identity/api/tenants/$($ID)"  

                    # --- Run vRA REST Request
                    Invoke-vRARestMethod -Method DELETE -URI $URI -Verbose:$VerbosePreference | Out-Null
                }
            }
            catch [Exception]{

                throw
            } 
        }
    }
    end {
        
    }
}