BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-29-2012, 04:01 PM   #1 (permalink)
CrackBerry Addict
 
Join Date: Jan 2008
Model: 9700
PIN: N/A
Carrier: Rogers
Posts: 709
Post Thanks: 0
Thanked 8 Times in 8 Posts
Default Populate Mobile Number from BES to Active Directory

Please Login to Remove!

Thought I'd share my script - I didn't immediately find anything I could use so I created this. Adjust as needed (especially the variables at the beginning!)

Code:
setlocal ENABLEDELAYEDEXPANSION

Set BESServerInstance=Server\BLACKBERRY
set MailServer=exchange
set BESUsers=0
set UsersUpdated=0
set FromEmailAddress=You@yourdomain.com
set ToEmailAddress=Them@yourdomain.com

bcp "set nocount on SELECT RIGHT(besmgmt.dbo.SyncDeviceMgmtSummary.PhoneNumber, 10) AS Expr1, besmgmt.dbo.UserConfig.DisplayName FROM besmgmt.dbo.SyncDeviceMgmtSummary INNER JOIN besmgmt.dbo.UserConfig ON besmgmt.dbo.SyncDeviceMgmtSummary.UserConfigId = besmgmt.dbo.UserConfig.Id WHERE (RIGHT(besmgmt.dbo.SyncDeviceMgmtSummary.PhoneNumber,10) <> N'')" queryout "%~dp0Output.txt" -c -t, -S "%BESServerInstance%" -T

type "%~dp0BES2ADHeader.txt" > "%~dp0Email.txt"

for /f "usebackq tokens=1* delims=," %%i in ("%~dp0output.txt") do (
	set /a BESUsers+=1
	set PhoneNumber=%%i
	set PhoneNumberFormatted=^(!PhoneNumber:~0,3!^) !PhoneNumber:~3,3!-!PhoneNumber:~6!
	echo !PhoneNumberFormatted!
	dsquery user -name "%%j" | dsget user -mobile | find "!PhoneNumberFormatted!"
	if errorlevel 1 (
		set /a UsersUpdated+=1
		dsquery user -name "%%j" | dsmod user -mobile "!PhoneNumberFormatted!"
		echo %%j: !PhoneNumberFormatted! >> "%~dp0Email.txt" 
	)
)

echo.>> "%~dp0Email.txt"
echo Total BES Users: %BESUsers% >> "%~dp0Email.txt"
echo Total BES Users Updated: %UsersUpdated% >> "%~dp0Email.txt"

if %UsersUpdated% GTR 0 "%~dp0blat" "%~dp0Email.txt" -q -to %ToEmailAddress% -s "BES to AD Update" -priority 1 -f %FromEmailAddress% -server %MailServer%
You need blat to email out, and bcp.exe and bcp.rll to run this (in the same directory or within a known path). It also has to be either run as a Trusted Windows account, or you'll have to provide the sa name and change the credentials bcp uses to fetch the data.
Offline  
The Following User Says Thank You to TargetIT For This Useful Post:
knottyrope (05-29-2012)
Old 05-29-2012, 04:35 PM   #2 (permalink)
CrackBerry Addict
 
Join Date: Jan 2008
Model: 9700
PIN: N/A
Carrier: Rogers
Posts: 709
Post Thanks: 0
Thanked 8 Times in 8 Posts
Default Re: Populate Mobile Number from BES to Active Directory

Ironically, I posted in this:

Sync BES mobile numbers to Active Directory

But I made a few enhancements since.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Populate Mobile Number from BES to Active Directory
Thread Thread Starter Forum Replies Last Post
"LOOKUP" function retrieve SIM mobile number from BES SQL config database - HELP!!! bbqueen@cox.net General BlackBerry Discussion 0 12-19-2008 07:51 AM
[2005-10-31] Pocket Express™ for BlackBerry™ Wins Gold Star in Mobile Village® Awards EricHandmark BlackBerry In the News 0 10-31-2005 10:04 AM

Deltrol Controls 166 SPST-NO COIL 18 VDC Relay. 4 Pin
$19.99
Deltrol Controls 166 SPST-NO COIL 18 VDC Relay. 4 Pin picture150181 New-No Box, Allen-Bradley 69A86 Operating Coil 110V 50Hz, 120V 60Hz
$48.4
150181 New-No Box, Allen-Bradley 69A86 Operating Coil 110V 50Hz, 120V 60Hz picture150175 New-No Box, Allen-Bradley PA236 Contactor Coil, 115-120V 60Hz
$38.58
150175 New-No Box, Allen-Bradley PA236 Contactor Coil, 115-120V 60Hz picture150091 Old-Stock, Numatics 237-214B Solenoid Coil
$77.4
150091 Old-Stock, Numatics 237-214B Solenoid Coil pictureFiretrol FTA330-K Size 4 1/2 Contactor 3 Pole 150Hp 220 Amp 600V 460-550V Coil
$120.0
Firetrol FTA330-K Size 4 1/2 Contactor 3 Pole 150Hp 220 Amp 600V 460-550V Coil  picture






Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.