Hello,
Firstly, all value references in Adaxes scripts must be wrapped into double quotes. As such, the corresponding line in your script must be as follows:
$rmCapacity = "%param-Capacity%"
As for the error itself, it looks like it occurs inside of the Set-Place cmdlet (pay attention to the number of the line in the error). As per our check, there are known issues with the cmdlet that can result in such an error. The following thread on Microsoft forums might be helpful: https://answers.microsoft.com/en-us/msoffice/forum/all/set-place-command-and-room-finder/529ec10f-52b8-45cc-aaa5-8029c1f5422f.
As per our check, you can also use the -ResourceCapacity parameter of the Set-Mailbox cmdlet. It looks to be more reliable. In this case, your script will be as follows:
Import-Module ExchangeOnlineManagement
$rmCapacity = "%param-Capacity%"
# Get the username in Office 365
try
{
$objectId = [Guid]$Context.TargetObject.Get("adm-O365ObjectId")
}
catch
{
$Context.LogMessage("The user doesn't have an Office 365 account", "Warning")
return
}
try
{
# Connect to Exchange Online
Connect-ExchangeOnline -Credential $Context.GetOffice365Credential()
# Change mailbox capacity
Set-Mailbox $objectId.ToString() -ResourceCapacity $rmCapacity
}
catch
{
$Context.LogMessage($_.Exception.Message, "Warning")
}
finally
{
# Close the remote session and release resources
Disconnect-ExchangeOnline -Confirm:$false
}
If you still need to use the Set-Place cmdlet and the forum thread does not help, please, specify the difference when running the custom command manually and from a scheduled task. Is it done for the very same account? Is the account in the scope of a Microsoft 365 tenant in Adaxes? Any additional details will be very helpful.