The script saves last activity date of the target user in Exchange Online to custom attribute date attribute. To execute the script, create a custom command, scheduled task or business rule configured for the User object type.
In the script, the $propertyName variable specifies the LDAP name of the custom date attribute that will store the last activity date.
PowerShell
$propertyName = "adm-CustomAttributeDate1" # TODO: modify me
# Check recipient type and location
if ($Context.TargetObject.RecipientLocation -ne "ADM_EXCHANGERECIPIENTLOCATION_EXCHANGEONLINE" -or
$Context.TargetObject.RecipientType -ne "ADM_EXCHANGERECIPIENTTYPE_MAILBOXENABLED")
{
return
}
# Get last logon date from Exchange Online
$mailboxParams = $Context.TargetObject.GetMailParameters()
$lastLogonDate = $mailboxParams.UsageInfo.LastLogonDate
if ($lastLogonDate -eq [DateTime]::MinValue)
{
return
}
# Update the user
$Context.TargetObject.Put($propertyName, $lastLogonDate)
$Context.TargetObject.SetInfo()
we used this script, without modification, but somehow now it is not working anymore.
Exception calling "GetMailParameters" with "0" argument(s): "The recipient has neither a mailbox nor an e-mail address. Stack trace: at <Scriptblock>, <No file>:line 11
Do you have any idea what should I change?
Please, specify the version of Adaxes you are currently using. For details on how to check it, see https://www.adaxes.com/help/CheckServiceVersion.
Also, make sure that the account you run the script against is associated with a Microsoft 365 tenant in Adaxes. For information on how to check that, see https://www.adaxes.com/help/LookupTenantForUser.
so our version is 3.14.19312.0
the user for the tenant is good, we already have different queries and everiyhing else working except this script. We used this for a long time, nobody changed it and it broked somehow. I think maybe Microsoft changed something, but I cannot prove this. If you have a modified script or you can test in your environment, please do it for us. Thx
Microsoft has followed through with its plan to deprecate remote PowerShell in Exchange Online, and it is not available in your tenant anymore. The Adaxes version you are using relies on PowerShell remoting to perform operations in Exchange Online, which means you need to update to a version that uses the Exchange Online Management V3 PowerShell module. You have a choice between updating to Adaxes 2021 Update 7 and upgrading to the latest version.
Upgrade Instructions
Adaxes 2021 Update 7
Download
What's New
Adaxes 2023.2 Update 3
Download
What's New
If you decide to upgrade to the latest version, we recommend you to first check whether your current license key can be used with it. For details, see https://www.adaxes.com/help/CheckUpdates/.
Unfortunately, there was a mistake in the script. We have just corrected it. Please, give the updated script a try. Should you face any errors/warnings, please, send screenshots to support@adaxes.com.
We are running Admin Console v2023.2
Adaxes Service v3.16.21906.0
Each environment of the latest version has 15 custom date attributes: adm-CustomAttributeDate1 - adm-CustomAttributeDate15. You can use any of them. There is no need to change anything else in the script.