# Update MFA phone number for Lesley Roth @ BG Builders
$ErrorActionPreference = "Stop"
$lesleyUPN = "lesley@bgbuildersllc.com"
$newPhone = "+1 4804954511"
$tenantId = "ededa4fb-f6eb-4398-851d-5eb3e11fab27"

Import-Module Microsoft.Graph.Authentication
Connect-MgGraph -TenantId $tenantId -Scopes 'UserAuthenticationMethod.ReadWrite.All' -NoWelcome

$mobileMethodId = "3179e48a-750b-4051-897c-87b9720928f7"

Write-Output "Current: +1 4802299138"
Write-Output "Changing to: $newPhone"

$body = @{ phoneNumber = $newPhone; phoneType = "mobile" } | ConvertTo-Json
Invoke-MgGraphRequest -Method PUT -Uri "https://graph.microsoft.com/v1.0/users/$lesleyUPN/authentication/phoneMethods/$mobileMethodId" -Body $body -ContentType "application/json"

Write-Output "[OK] Phone updated"

# Verify
$methods = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/users/$lesleyUPN/authentication/phoneMethods"
foreach ($m in $methods.value) {
    Write-Output "Verified: $($m.phoneType) = $($m.phoneNumber)"
}

Disconnect-MgGraph
