Hi all,
We currently have a bunch of dial plans that we assign to new users via Adaxes.
We updated Adaxes to the latest version, and moved it to a new server before the end of the year, alongside adding our Azure AD domain to try and manage that as well. It seems like during this (or conveniently around the same time), the scripts have broken and no longer do anything.
During user creation, we use extension attribute 1 and 2 - 1 is 'TeamsIncomplete', and 2 is the user's extension. Once these scripts run successfully, they are supposed to set these values to null.
The script is as follows:
# Get saved credentials
$username = $Context.RunAs.UserName
$password = $Context.RunAs.Password | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PsCredential($username, $password)
try
{
# Get the object ID in Microsoft 365
$objectId = ([Guid]$Context.TargetObject.Get("adm-O365ObjectId")).ToString()
}
catch
{
return # The user doesn't have a Microsoft 365 account
}
try
{
# Get the user in Microsoft Teams
Connect-MicrosoftTeams -Credential $credential
$user = Get-CsOnlineUser -Filter "Identity -eq '$objectId'"
if ($NULL -eq $user)
{
$Context.LogMessage("The user does not have a Microsoft Teams account", "Information")
return # User does not exist in Microsoft Teams
}
#Set-CsUser -Identity $user.Identity -EnterpriseVoiceEnabled $true -HostedVoiceMail $true
#25/07/22 - Removed the above line to replace with one that enables Enterprise Voice and adds an phonenumber and extension
#to enable transferring teams calls to PSTN lines
#The "-EnterpriseVoiceEnabled" flag is no longer required, as it is automatically included when a phone number is added.
Set-CsPhoneNumberAssignment -Identity $user.Identity -PhoneNumber "+555-5555-555;ext=%extensionAttribute2%" -Phonenumbertype DirectRouting
Grant-CsOnlineVoiceRoutingPolicy -Identity $user.Identity -PolicyName “Worldwide”
Grant-CsCallingLineIdentity -Identity $user.Identity -PolicyName "No DDI"
#Clear ExtensionAttribute1 (Teams configuration flag) to indicate Teams is now configured
#25/07/22 - Added Extensionattribute2 (Teams Extension) as well.
$context.Targetobject.put("extensionAttribute1", $null)
$context.TargetObject.Put("extensionAttribute2", $null)
$context.Targetobject.Setinfo()
}
finally
{
# Close the connection and release resources
Disconnect-MicrosoftTeams
}
At the moment, the script runs each night on the same users, as it seems the script is failing early on in the process. Manually running it, it runs for around 12 seconds, then stops - there are no errors in the management/execution log - it only shows that the scripts run for the same users every time.
Can anyone advise if this script should still work? If so, perhaps there is some other issue with Adaxes causing this?
When attempting to view the 'resolved value references' for an account, the 'adm-o365objectid' doesn't change into a value - perhaps this value has been removed/broken in new versions of adaxes?
Cheers all.