I'm more of a scripting guy and came up with this:
Code:
setlocal ENABLEDELAYEDEXPANSION
sqlcmd -U "username" -P "password" -S "servername\instance" -d besmgmt -Q "set nocount on SELECT RIGHT(dbo.SyncDeviceMgmtSummary.PhoneNumber, 10) AS Expr1, dbo.UserConfig.DisplayName FROM dbo.SyncDeviceMgmtSummary INNER JOIN dbo.UserConfig ON dbo.SyncDeviceMgmtSummary.UserConfigId = dbo.UserConfig.Id WHERE (RIGHT(dbo.SyncDeviceMgmtSummary.PhoneNumber,10) <> N'')" -o Output.txt -W -h -1
for /f "tokens=1*" %%i in (output.txt) do (
set PhoneNumber=%%i
set PhoneNumberFormatted=^(!PhoneNumber:~0,3!^) !PhoneNumber:~3,3!-!PhoneNumber:~6!
find "%%j" SupressList.txt
if errorlevel 1 dsquery user -name "%%j" | dsmod user -mobile "!PhoneNumberFormatted!"
)
It's not quite as slick for some obvious reasons, but it works. There's a supresslist.txt file that will prevent some names/numbers from being published (a requirement we had).