Quit remote script as failure

0

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

    
asked by anonymous 30.05.2017 / 16:19

1 answer

0

I was able to resolve using the throw command "error message", this command also sends the returnCode = 1 and stops executing the script and my orchestration stream receives the returncode and treats as failure:)

    
30.05.2017 / 20:04