Add cloud only group upon user cloud creation

Hello 

Context: Active Role Server 8.2.1, Azure

I am trying to do ‘Group Membership AutoProvisioning’ on cloud-only users for cloud-only groups. My goal is that when I create a cloud-only account via Active Role, the new account is automatically added to a list of cloud-only groups.

I tried to do this via a policy, but I get this error message: " Search failed. Path = CN=a4gkslod56bdhjdsj...., CN=Security Groups, CN=toto.onmicrosoft.com,CN=Azure,CN=configuration' was not found " but the group exist in my tenant. 

I have try to do it in a script execution in the policy like so:

 function assgin-Group($Request) {
    	
    $context.O365ImportModules(@(
        "Microsoft.Graph.Users",
        "Microsoft.Graph.Groups",
        "Microsoft.Graph.Authentication"
    ))


$idgroup1="a4d9f62d-fbad-42c7-b6b8-f7fac2880ed5"
$userid=$Request.Get("edsaAzureUserId")
$cmd="New-MgGroupMember -GroupId $idgroup1 -DirectoryObjectId $userid"
$context.O365ExecuteScriptCmd($cmd)
$context.O365RemoveAllModulesSessions()
}

on a fonction onPostCreat but it doesn't work. 

I have try to do it in a workflow.

If anyone has encountered this problem before or has any ideas, I'm all ears.