-First export the numbers from the Extension list to a .csv file using data - get data - from file

-Once exported, clean up the data as much as possible, deleting empty rows, headers and lines without mobile numbers etc

- Then use the script below, ensure to change the second line to the correct file path of your csv.

----------------------------------------start script---------------------------------------------------------

# Import the CSV file

$csvData = Import-Csv -Path "C:\\temp\\Entity Staff Extension List1.csv"


# Loop through each record in the CSV file

foreach ($record in $csvData) {

    # Get the user from Active Directory

    $adUser = Get-ADUser -Filter "Name -eq '$($record.Name)'" -Properties MobilePhone


    # Check if the user exists in Active Directory

    if ($adUser) {

        # Output the current user being processed

        Write-Host "Processing $($record.Name). Found matching record $($adUser.Name) in Active Directory."


        # Ask for confirmation before updating

        $confirmation = Read-Host "Do you want to update the mobile number of $($adUser.Name) to $($record.MobileNumber)? [Y/N]"

        if ($confirmation -eq 'Y') {

            # Update the mobile number in Active Directory

            Set-ADUser -Identity $adUser -MobilePhone $record.MobileNumber

            Write-Host "Updated the mobile number of $($adUser.Name)."

        } else {

            Write-Host "Skipped updating the mobile number of $($adUser.Name)."

        }

    } else {

        Write-Host "No matching record found in Active Directory for $($record.Name)."

    }

}


-----------------------------------------end script------------------------------------------------------------