Follow

Delete Workspace tenant

Table of Contents

 

Overview

As an admin it is possible to delete a Workspace from your instance. This is easily done by using the PowerShell script below. 

We recommend using this method when deleting tenants.

You can open PowerShell with administrator privileges, adjust two values and run the script below. After filling in the Global Admin account credentials, filling in the environment name and confirm, the tenant will be deleted. 

 

Delete tenant script

As an admin it is possible to delete a Workspace from your instance. You need to update the $hostname and $provisioningKey to own parameters. The Provisioningskey is known internally.


#Set TLS communication to only 1.2. Other is not supported. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$hostName = 'DOMAIN' # Enter the hostname of the Workspace365, dont include https or the environment name.
$provisioningKey = 'KEY' # Enter the Provisioningskey which is located in the NDAW.HTML.Front.config
$environmentNameRaw = Read-Host -Prompt "Enter Environment Name"
$environmentName = $environmentNameRaw.ToLower() if (![string]::IsNullOrEmpty($environmentName)) { $confirmation = Read-Host -Prompt "Are you sure you want to delete the environment: $environmentName ?" if ($confirmation -eq "y" -or $confirmation -eq "Y" -or $confirmation -eq "Yes" -or $confirmation -eq "yes"){
Try
{
Invoke-RestMethod -Method DELETE -Uri "https://$hostName/Provisioning/Environment/$environmentName/" -ContentType "application/json" -Header @{ 'ProvisioningKey' = $provisioningKey } -ErrorVariable RestError;
Write-Host "Succesfully deleted environment $environmentName" -ForegroundColor Green;
}
catch
{
$HttpStatusCode = $RestError.ErrorRecord.Exception.Response.StatusCode.value__
$HttpStatusDescription = $RestError.ErrorRecord.Exception.Response.StatusDescription

Write-Host "Environment deletion failed with error code: $($HttpStatusCode) and error description: $($HttpStatusDescription)" -ForegroundColor Red;
}
} else {
Write-Host "Environment deletion of environment: $environmentName canceled" -ForegroundColor Yellow;
} }

Back to top