Hey all,
I'm trying to write a function in PowerShell where before running the onClick handler it does some basic error checking and if it finds an error to exit the onClickHandler. But it's not returning my return command like I'm used to in LUA.
So this is my onClick function:
$FindButtonClick = {
If (!$InputBox.Text) { $inputBoxText = $Null }
errorCheck $chosenIDType $inputBoxText $chosenDB $AuditDB.checked
Get-AdPartition $chosenIDType $InputBox.Text $chosenDB -audit:$AuditDB.checked
}
Here is the errorCheck function that gets called
function global:errorCheck ($chosenIDType, $InputBox, $chosenDB, $AuditCB) {
If ($chosenIDType -eq "Unchosen") {
$errorMSG = "No Lookup Type Chosen.`nPlease choose a Lookup Type and try again."
$errorReason = "NoIDError"
$isError = $True
} ElseIf ($InputBox -eq $Null) {
$errorMSG = "No" + $chosenIDType +"entered.`nPlease enter an ID in the text box."
$errorReason = "NoLookUpError"
$isError = $True
}
If ($isError) {
errorNotice $errorMSG $errorReason #This function opens an error dialog
return return
}
}
I'm trying to make it so that if $isError resolves to $True that it returns "return" so that the Get-AdPartition Cmdlet in my onClick doesn't run. The error I'm getting just tells me "return : The term 'return' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
Any ideas?