I want the remote script in a given condition to terminate with error and exit as failure.
if (($siteExists -eq $null) -and ($siteExistsInRecycleBin -eq $null)) {
write-output "info: Creating $($SiteCompleto)"
New-SPOSite -Url $SiteCompleto -title $TituloFinal -Owner $Proprietario -StorageQuota '5' -NoWait -ResourceQuota '100' -Template 'STS#0'
}
elseif ($siteExists -eq $true){
write-output "info: $($SiteCompleto) already exists"
stop
}
else{
write-output "info: $($SiteCompleto) still exists in the recyclebin"
stop
I need in case the sharepoint site already exists that the script is stopped and quit as if there was a runtime error, something similar to kill -9 of the linux scripts. I'm running this script remotely through an orchestrator that only addresses success or failure.
As the stop command does not exist, the effect when I use it the result is what I want, it aborts the script with error, but in fact the code is wrong and the solution is not elegant