Forum Discussion
danikoershuis
Feb 03, 2025Copper Contributor
I tried to make a script to change a phone number in auto attendent teams
Hello,
i want to create a powershell script where i can change the Auto attendant of the teams admin so that users can change the phone number of the after hours without having a teams admin license, does anyone know how i can change the number of the Auto attendants using powershell?
Its in Auto attendants -> your Auto attendant -> Call flow for after hours -> Call routing options - > redirect call -> phone number that i want to change using powershell.
I made a script but it does not seem to work. could someone please tell me what is wrong with it?
# connect with teams
Connect-MicrosoftTeams
# Set up variable
$AutoAttendantId = "3d7ff2b0-1b1e-4bd8-92c3-cb4e3316d6be"
$NewPhoneNumber = "+31625450875"
# Get auto attendant
$AA = Get-CsAutoAttendant -Identity $AutoAttendantId
if (-not $AA) {
Write-Host "Auto Attendant not found. Please check the ID." -ForegroundColor Red
Exit
}
# Go to after hours
$AfterHoursCallFlow = $AA.CallFlows | Where-Object { $_.Name -like "*After hours*" }
if (-not $AfterHoursCallFlow) {
Write-Host "After Hours Call Flow not found. Please check the settings." -ForegroundColor Red
Exit
}
# go to menu screen of phone number
$AfterHoursCallFlow.CallRouting | ForEach-Object {
if ($_.Type -eq "PhoneNumber") {
$_.PhoneNumber = $NewPhoneNumber
}
}
# Update de Auto Attendant with new settings
Set-CsAutoAttendant -Instance $AA
# Show tekst that its completed
Write-Host "Phone number updated successfully to $NewPhoneNumber" -ForegroundColor Green
- Andres-BohrenSteel Contributor
Please stick to one Thread