Hello Mark,
According to the article you referenced, you can disable the access by just using the below script.
try
{
# Get the object ID in Microsoft 365
$objectId = [Guid]$Context.TargetObject.Get("adm-AzureId")
}
catch
{
return # The user doesn't have a Microsoft 365 account
}
# Connect to Exchange Online
$Context.CloudServices.ConnectExchangeOnline()
# Disable Exchange Online PowerShell access
Set-User -Identity $objectId -EXOModuleEnabled $false
Unfortunately, there does not seem to be an easy way to check the status for a single user. The command provided in the article returns a bunch of formatted text and trying to parse it in the script is nearly impossible.
As for the OUs you want to target, they should just be added to the Activity Scope of the scheduled task. For details on how to create those in Adaxes, see https://www.adaxes.com/help/ScheduleTasksForDirectoryManagement.