This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Policy Script to disable Exchange mailbox creation based on attribute does not work

Script without if works:

function onGetEffectivePolicy( $Request ) {
    $Values = @( "a, "b" )
    $Attribute = "extensionAttribute13"
    $Request.SetEffectivePolicyInfo( $Attribute, $Constants.EDS_EPI_UI_DISPLAY_NOTE, "The Drop Down List 'Mailbox Type' is generated by Policy 'Set Azure AD Mailbox'" )
    $Request.SetEffectivePolicyInfo( $Attribute, $Constants.EDS_EPI_UI_POSSIBLE_VALUES, $Values )
    $LALA = $Request.get("extensionattribute13")
    $Request.ClearEffectivePolicyInfo( "edsaCreateMsExchMailbox", $Constants.EDS_EPI_UI_GENERATED_VALUE )
    $Request.ClearEffectivePolicyInfo( "edsaCreateMsExchMailbox", $Constants.EDS_EPI_UI_AUTO_GENERATED )
    $Request.SetEffectivePolicyInfo( "edsaCreateMsExchMailbox", $Constants.EDS_EPI_UI_GENERATED_VALUE, "False" )
    $Request.SetEffectivePolicyInfo( "edsaCreateMsExchMailbox", $Constants.EDS_EPI_UI_AUTO_GENERATED, "False" )
}

 

 

Script with if clause does not work:

function onGetEffectivePolicy( $Request ) {
    $Values = @( "a, "b" )
    $Attribute = "extensionAttribute13"
    $Request.SetEffectivePolicyInfo( $Attribute, $Constants.EDS_EPI_UI_DISPLAY_NOTE, "The Drop Down List 'Mailbox Type' is generated by Policy 'Set Azure AD Mailbox'" )
    $Request.SetEffectivePolicyInfo( $Attribute, $Constants.EDS_EPI_UI_POSSIBLE_VALUES, $Values )
    $LALA = $Request.get("extensionattribute13")
    if ($LALA -eq "a") {
       
        $Request.ClearEffectivePolicyInfo( "edsaCreateMsExchMailbox", $Constants.EDS_EPI_UI_GENERATED_VALUE )
        $Request.ClearEffectivePolicyInfo( "edsaCreateMsExchMailbox", $Constants.EDS_EPI_UI_AUTO_GENERATED )
        $Request.SetEffectivePolicyInfo( "edsaCreateMsExchMailbox", $Constants.EDS_EPI_UI_GENERATED_VALUE, "False" )
        $Request.SetEffectivePolicyInfo( "edsaCreateMsExchMailbox", $Constants.EDS_EPI_UI_AUTO_GENERATED, "False" )    
    }
}

 

 

Why if I add a if the create an exchange mailbox checkbox is checked?
The Attribute has the correct value and the if clause is true -> This is tested!

 

Can anybody help me?

 

Best Regards

Christoph

Parents Reply Children
No Data