Abort Granfeldt PSMA script and pass status back to MIM.

tmunro55 351 Reputation points
2020-12-17T20:53:03.363+00:00

Hello,

I have a situation where I need to abort a Granfeldt PSMA script in the BEGIN block. What I can’t figure out is what MIM is expecting back so I can show a result of failed. Following is the snippet of code I'm talking about.

$Configuration = "C:\MIMPowerShellResources\Environment.json"
if(test-Path $Configuration) {
    $Config = Get-Content $Configuration | ConvertFrom-JSON
    $Running_Environment = $Config.Running_Environment
    $data_source = $Config.Data_Source.$Running_Environment
} else {
    $retObj = @{}
    $retobj."[ErrorName]" = 'failed'
    $retobj."[ErrorDetail]" = 'Config file missing'
    $retobj
    Break
}

I need to abort the script and pass back a status of "failed". I'm always getting "success".

Any help would be greatly appreciated.

Microsoft Identity Manager
Microsoft Identity Manager
A family of Microsoft products that manage a user's digital identity using identity synchronization, certificate management, and user provisioning.
706 questions
0 comments No comments
{count} votes

Accepted answer
  1. SteinIP 271 Reputation points
    2021-01-15T12:27:36.017+00:00

    I think you need to throw an error to abort. That can be fancy using an appropriate exception or simple:
    throw "Config file missing"

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. tmunro55 351 Reputation points
    2021-05-06T15:57:02.49+00:00

    Thank you. Sounds easy enough.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.