none
List Exchange-ActiveSync Device Partnerships

    Pergunta

  • I'm running an mixed Exchange environment with an Exchange 2007 CAS and Exchange 2003 Back-End.   Is there a way to get a list of all the mobile devices that have a partnership with Exchange?   I can do it by manually entering everyones smtp address in the MobileAdmin tool one at a time but that is not very efficient.

    I tried using the management shell on the CAS server but i didnt have any luck (could be my poor powershell skills).   I can list all the mailboxes on the 2003 server but cant get activesync device statistics on any of them using the shell. 

    Thanks,
    segunda-feira, 19 de maio de 2008 18:05

Todas as Respostas

  • Hi Jamichel,
    Did you get anywhere with this? I'm facing exactly the same issue.

    Cheers.
    sexta-feira, 1 de maio de 2009 09:13
  • I found this that does the job for Excahnge 2007:
    http://knicksmith.blogspot.com/2007/03/dst-and-mobile-devices.html
    In case the link above nolonger exists, google "Get-ActiveSyncDeviceStatistics"

    Unfortunately I have Exchange 2003 so I'm still stuck at the moment.

    sexta-feira, 1 de maio de 2009 09:20
  • Just to clear this up.

    In Exchange 2003 you can use the ActiveSync Web Administration Tool to list and manage Device Partnerships. You need to log into the MobilAdmin Web site.

    In Exchange 2007 you can use Powershell to retrieve the Device Partnerships :

    Get-Mailbox | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity} | ft DeviceFriendlyName, Devicetype, DeviceUserAgent

    In Both Exchange 2003 and Exchange 2007 you can use Log Parsing to extract the ActiveSync data and analyse the number of devices, their type and lots of interesting statistics. If you really want to know what’s happening then have a look at Log Parser. For help check out the unofficial Log Parser Forums.

    Cheers Wayne
    Airloom

    segunda-feira, 4 de maio de 2009 02:44
  • Just to clear this up.

    In Exchange 2003 you can use the ActiveSync Web Administration Tool to list and manage Device Partnerships. You need to log into the MobilAdmin Web site.

    <SNIP>


    Cheers Wayne
    Airloom

    Just to clarify further - the web admin tool only lets you list all the mobile devices for one user at a time. You have to type in that users mailbox name to list their devices.

    The log parser sounds like a possibility though. Thanks Wayne.
    segunda-feira, 11 de maio de 2009 16:09
  • This seemed to do the job for me (YMMV) :
    1. install the MS logparser:
      http://www.microsoft.com/downloads/details.aspx?familyid=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en
    2. create a folder called c:\public
    3. create text file called Hits_By_User.sql with the following contents:
      SELECT 
      
                  TO_LOWERCASE (cs-username) AS User,
      
                  MyDeviceType                            AS DeviceType,
      
                  COUNT(*)                                 AS Hits,
      
                  SUM (MySync)                           AS Syncs,
      
                  SUM (MyFolderSync)                  AS Folder_Syncs,
      
                  SUM (MyPing)                            AS Pings,
      
                  SUM (MySendMail)                     AS Emails_Sent,
      
                  SUM (MySmartReply)                  AS SmartReplies,
      
                  SUM (MyMeetingResponse)         AS Meeting_Responses,
      
                  SUM (MyGetAttachment)             AS Get_Attachments
      
      USING
      
                  SUBSTR (cs-uri-query, ADD (INDEX_OF (cs-uri-query, 'DeviceType='), 11),
      
                  INDEX_OF (SUBSTR(cs-uri-query, ADD (INDEX_OF (cs-uri-query, 'DeviceType='), 11)), '&')) AS MyDeviceType,
      
       
      
                  SUBSTR (cs-uri-query, ADD (INDEX_OF (cs-uri-query, 'Cmd='), 4),
      
                  INDEX_OF (SUBSTR(cs-uri-query, ADD (INDEX_OF (cs-uri-query, 'Cmd='), 4)), '&')) AS MyCmd,
      
       
      
                  CASE MyCmd
      
                              WHEN 'Sync' THEN 1
      
                              ELSE 0
      
                  END AS MySync,
      
                 
      
                  CASE MyCmd
      
                              WHEN 'Ping' THEN 1
      
                              ELSE 0
      
                  END AS MyPing,
      
       
      
                  CASE MyCmd
      
                              WHEN 'SendMail' THEN 1
      
                              ELSE 0
      
                  END AS MySendMail,
      
       
      
                  CASE MyCmd
      
                              WHEN 'SmartReply' THEN 1
      
                              ELSE 0
      
                  END AS MySmartReply,
      
       
      
                  CASE MyCmd
      
                              WHEN 'MeetingResponse' THEN 1
      
                              ELSE 0
      
                  END AS MyMeetingResponse,
      
                 
      
                  CASE MyCmd
      
                              WHEN 'GetAttachment' THEN 1
      
                              ELSE 0
      
                  END AS MyGetAttachment,
      
       
      
                  CASE MyCmd
      
                              WHEN 'FolderSync' THEN 1
      
                              ELSE 0
      
                  END AS MyFolderSync
      
      /* CSV
      
      If you want to output to CSV, you will need to add the cmd-line parameter -o:CSV
      
      EXAMPLE: LogParser.exe -i:IISW3C -o:CSV file:c:\Public\LogParser\SQL\User_Activity.sql
      
      */
      
      /**************Input-output settings **************/
      
      INTO C:\Public\LogParserOutput\Hits_By_User.csv
      
      FROM C:\WINDOWS\system32\LogFiles\W3SVC1\*.log
      
      /**********************************************/
      
      
      WHERE cs-uri-stem = '/Microsoft-Server-ActiveSync'
      
      GROUP BY User, DeviceType
      
      ORDER BY DeviceType, Hits DESC
          
    4. Create a text file called Hits_By_User.bat with the following contents:
      "C:\Program Files\Log Parser 2.2\logparser.exe" -i:IISW3C file:c:\public\Hits_By_User.sql
    NB make sure the Input-output settings in the sql file match your configuration.
    You can find your logfile location in properties for the website in IIS

    All credit due to msexchangeteam.com for the code:
    http://msexchangeteam.com/archive/2006/02/14/419562.aspx

    All the best

    M.Ozin
    • Editado ozinm segunda-feira, 11 de maio de 2009 17:12 Corrected formatting
    segunda-feira, 11 de maio de 2009 17:08
  • Hi Wayne,

    thanks for posting the script in here:

    Get-Mailbox | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity} | ft Alias, Mailbox, DeviceFriendlyName, Devicetype, DeviceUserAgent
    However, the above script doesn't show the respective mailbox name, therefore i don't know who owns which device ?

    any clue in how to show the user column ?
    /* Windows Infrastructure Support Engineer */
    quarta-feira, 30 de setembro de 2009 08:19
  • Albert,

    You could try :
    Get-Mailbox | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity} | ft DeviceFriendlyName, Devicetype, DeviceUserAgent, Identity

    The Active Sync Dveice doesn't have a user field to disply but it does have an Identity which does show the user/device. If the Identity is truncated, you could use :
    Get-Mailbox | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity} | fl DeviceFriendlyName, Devicetype, DeviceUserAgent, Identity

    Cheers Wayne
    Airloom
    quinta-feira, 1 de outubro de 2009 01:11
  • Thanks Wayne.

    it works now :-)

    /* Windows Infrastructure Support Engineer */
    quinta-feira, 1 de outubro de 2009 21:13
  • Try this:

    $mbx = get-casmailbox -Filter {HasActivesyncDevicePartnership -eq $true -and -not DisplayName -like "CAS_{*"}; $mbx | foreach {$name = $_.name; $device = get-activesync devicestatistics -mailbox $_.identity; $device | foreach {write-host $mbx.name, $_.devicemodel, $_.devicephonenumber, $_.deviceid, $_.FirstSyncTime, $_.LastSuccessSync} }

    Exchange Server 2007: Listing Exchange ActiveSync users and device information


    --
    Bharat Suneja
    Microsoft Corporation
    blog: exchangepedia.com/blog

    This posting is provided "AS IS" with no warranties, and confers no
    rights. Please do not send email directly to this alias. This alias is for
    newsgroup purposes only.
    ----------------------------
    quarta-feira, 25 de novembro de 2009 17:41
  • Awesome!  Do you know how to grab the date?
    quinta-feira, 28 de outubro de 2010 21:54
  • I've successfully ran the above commands/scripts, meaning they ran without errors. However, I do not get any output at all... I did a simple test on my own mailbox, just to see what data is in there using this command: get-activesyncdevicestatistics -mailbox <smtpaddress>

    This is the output I get:

    FirstSyncTime         : 9/9/2010 10:48:41 AM
    LastPolicyUpdateTime  : 12/16/2010 3:56:55 PM
    LastSyncAttemptTime   : 12/16/2010 4:21:35 PM
    LastSuccessSync       : 12/16/2010 4:21:35 PM
    DeviceType            : iPhone
    DeviceID              : **********1VA4S
    DeviceUserAgent       : Apple-iPhone3C1/803.148
    DeviceWipeSentTime    :
    DeviceWipeRequestTime :
    DeviceWipeAckTime     :
    LastPingHeartbeat     : 600
    RecoveryPassword      : ********
    DeviceModel           :
    DeviceIMEI            :
    DeviceFriendlyName    :
    DeviceOS              :
    DeviceOSLanguage      :
    DevicePhoneNumber     :
    Identity              : emailaddress@company.com\AirSync-iPhone-**********1VA4S

    Why is there no data for DeviceModel, DeviceOS and the other fields? How can I get these populated?


    I find your lack of faith...Disturbing!
    quinta-feira, 16 de dezembro de 2010 16:59
  • Here's some links to a powershell based free tool that will find and return a list mobile device partnerships in Exch 2007/2010 environments.

    Find out more about it here.

    Download it here.

    • Sugerido como Resposta Matt Penner segunda-feira, 22 de julho de 2013 19:09
    segunda-feira, 28 de março de 2011 15:30
  • Sorry but I am new to PowerShell.  How would I get the following into .csv format with 6 independent columns?  Also, if I send this to a text file, I get the ... after each entry.  How do I correct that?

    Get-Mailbox | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity} | fl Identity, DeviceFriendlyName, Devicetype, DeviceUserAgent, FirstSyncTime, LastSuccessSync

    Thank you for the help.

    segunda-feira, 14 de novembro de 2011 13:40
  • Update:

    Seems that this did the trick.

    Get-Mailbox | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity} | Select-Object Identity, DeviceFriendlyName, Devicetype, DeviceUserAgent, FirstSyncTime, LastSuccessSync | export-csv c:\temp\test.csv

     

    • Sugerido como Resposta David S._ quinta-feira, 19 de janeiro de 2012 15:07
    segunda-feira, 14 de novembro de 2011 16:03
  • These work but how can i get the ActiveSyncMailboxPolicy that is also applied to each user and device in the same output?

    I use this now:

    Get-CASMailbox -resultsize unlimited |ft Displayname, ActiveSyncMailboxPolicy >c:\ActiveSync-policy.csv

    But it will not pipe into the same CSV.

    sexta-feira, 18 de novembro de 2011 19:06
  • See the example (by Daemon8814) right above your post:

    ft won't work, you have to use Select-Object insted.

     

    Good luck.

    terça-feira, 20 de dezembro de 2011 19:16
  • Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
    quarta-feira, 28 de dezembro de 2011 14:25
  • Not true...  John here you go... tested successfully.

    Get-CASMailbox -resultsize unlimited | select-object Displayname, ActiveSyncMailboxPolicy | out-file c:\ActiveSync-policy.csv

     


    Chris
    quarta-feira, 11 de janeiro de 2012 16:22
  • Thanks for the info, i am also trying to export a list of all active sync devices for my users without having to search one by one on Exchange 2003. I have looked at the powershell details above but not sure how to use them, when i run any of the commands above in powershell i get an error about the Get-Mailbox. Can anyone post a dummies guide to powershell and how to get these scripts to work? a link would also be cool.

    sábado, 17 de março de 2012 21:43
  • Yourmum90,

    You need to execute those Exchange specific commands from the Exchange Management Shell. Unfortunately, there's no native 2003 Exchange Shell--however, you can manage certain aspects from an Exchange 2007 server in the 2003 environment. I do not know if ActiveSync is one of those things. 

    quarta-feira, 28 de março de 2012 00:43
  • This post came up from Google search and hope I could find something very useful here. The original post asked if the list can be exported from Exchange Server 2003 not from Exchange 2007.  Does anyone have solution yet?

    sexta-feira, 4 de maio de 2012 15:39
  • Gia,
    I used to use this report for 2003 and its been great for our needs.
    Save the code as .vbs file, schedule it to run each week and boom - emails you a weekly report.

    As stated, You will need to add the names of your exchange servers to the search array, and update email bits (From, To, SMTP server).

    The script searches each mailbox on every exchange's mailstore and searches for the existance of a hidden folder - "Microsoft-Server-ActiveSync".  If it exists, it extracts any mobile data and dumps into a temporary file, then at the end, will email the HTML to yourself.

    We used to scan 10 exchange boxes and the results would come back 2 mins after running.

    '-----------------------------------------------------------------------------------------------
    '===============================================================================================
    ' TITLE:		ReportActiveSync.vbs
    '
    ' AUTHOR: 		Murray Wall, Glen Scales, Christian Sawyer 
    ' DATE  : 		25/09/2007 - Updated 21/10/2008
    ' EMAIL:		murray.wall@gov.sk.ca
    
    ' PURPOSE:		This script will report on any user with a hidden activesync folder in AD
    '			and determine if it is a smartphone, if so it will populate extensionAttribute1 with
    '			motorolaq and the date for use in a dynamic distribution list
    '
    ' PARAMETERS:	arrComputer = Add Exchange servers you want included in the report
    '				
    '		Update From	objEmail.From = "report@domainnameyouwant.com"
    '		Update To	objEmail.To = "emailaddresstosendto@domainnameyouwant.com"	
    '		Update SMTPServer
    '	objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpservername.domain.com"		
    '		Update File	set wfile = fso.opentextfile("c:\temp\sync.htm",2,true) 		
    '
    ' HOW TO USE:	cscript ReportActiveSync.vbs
    '
    ' NOTES:		This script is based on another one built by Glen Scales, and Christian Sawyer
    '				Thank's to all for the ideas
    '===============================================================================================
    
    
    REM servername = wscript.arguments(0)
    REM Problem with FQDN Use Netbios NamearrComputers = Array("Frontendexchange.company.com")
    arrComputers = Array("EXCHANGESERVER1","EXCHANGESERVER2","EXCHANGESERVER3")
    TotalDev=0
    
    For Each Servername In arrComputers
    
    set shell = createobject("wscript.shell")
    strValueName = "HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias"
    minTimeOffset = shell.regread(strValueName)
    toffset = datediff("h",DateAdd("n", minTimeOffset, now()),now())
    
    
    
    
    	'
    	'
    	'
    	'
    	'Set up the Table for the Report 
    	'
    	'
    	'
    	'
    	'
    
    
    
    
    report = "<table border=""1"" width=""100%"">" & vbcrlf
    report = report & "  <tr>" & vbcrlf
    report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">Name</font></b></td>" & vbcrlf
    report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">Email</font></b></td>" & vbcrlf
    report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">Device Type</font></b></td>" & vbcrlf
    report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">Device ID</font></b></td>" & vbcrlf
    report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">FolderSync</font></b></td>" & vbcrlf
    report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">Last Synced</font></b></td>" & vbcrlf
    report = report & "</tr>" & vbcrlf
    
    
    
    
    
    
    set req = createobject("microsoft.xmlhttp")
    set com = createobject("ADODB.Command")
    set conn = createobject("ADODB.Connection")
    Set iAdRootDSE = GetObject("LDAP://RootDSE")
    strNameingContext = iAdRootDSE.Get("configurationNamingContext")
    strDefaultNamingContext = iAdRootDSE.Get("defaultNamingContext")
    Conn.Provider = "ADsDSOObject"
    Conn.Open "ADs Provider"
    polQuery = "<LDAP://" & strNameingContext &  ">;(&(objectCategory=msExchRecipientPolicy)(cn=Default Policy));distinguishedName,gatewayProxy;subtree"
    svcQuery = "<LDAP://" & strNameingContext & ">;(&(objectCategory=msExchExchangeServer)(cn=" & Servername & "));cn,name,legacyExchangeDN;subtree"
    Com.ActiveConnection = Conn
    Com.CommandText = polQuery
    Set plRs = Com.Execute
    while not plRs.eof
    	for each adrobj in plrs.fields("gatewayProxy").value
    		if instr(adrobj,"SMTP:") then dpDefaultpolicy = right(adrobj,(len(adrobj)-instr(adrobj,"@")))
    	next
    	plrs.movenext
    wend
    
    
    Com.CommandText = svcQuery
    Set Rs = Com.Execute
    while not rs.eof	
    	GALQueryFilter =  "(&(&(&(& (mailnickname=*)(!msExchHideFromAddressLists=TRUE)(| (&(objectCategory=person)(objectClass=user)(msExchHomeServerName=" & rs.fields("legacyExchangeDN") & ")) )))))"
    	strQuery = "<LDAP://"  & strDefaultNamingContext & ">;" & GALQueryFilter & ";displayname,mail,distinguishedName,mailnickname,proxyaddresses;subtree"
    	com.Properties("Page Size") = 100
    	Com.CommandText = strQuery
    	Set Rs1 = Com.Execute
    	while not Rs1.eof
    		falias = "http://" & servername & "/exadmin/admin/" & dpDefaultpolicy & "/mbx/"
    		for each paddress in rs1.fields("proxyaddresses").value
    			if instr(paddress,"SMTP:") then falias = falias & replace(paddress,"SMTP:","")  & "/non_ipm_subtree"
    		next
    		SerachAsync(falias)
    		rs1.movenext
    	wend
    	rs.movenext
    wend
    
    report = report & "</table>" & vbcrlf
    newreport=newreport+report
    Next
    rs.close
    
    '-----------------------------------------------------------------------------------------------
    '===============================================================================================
    ' Write out the Temporary file and then Email it
    
    
    set conn = nothing
    set com = nothing
    Set fso = CreateObject("Scripting.FileSystemObject")
    set wfile = fso.opentextfile("c:\temp\sync.htm",2,true) 
    wfile.write newreport
    wfile.close
    set wfile = nothing
    set fso = nothing
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "ActiveSyncReporting@company.com"
    objEmail.To = "you@company.com"
    objEmail.Subject = "SyncReport as of " & formatdatetime(now(),2)
    objEmail.htmlbody = "<p><span style='font-size: 13px;'><span style='font-family: Arial,helvetica,sans-serif;'><b>Click <a href='https://frontend.company.com/mobileadmin'>here</a> for mobile administration.</b><p>Each blue heading row represents 1 exchange server and the users on that box.<br /></span></span></p>" & newreport
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTPSERVERNAME"
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    'objEmail.Headers.Add("message-id", "<3BD50098E401463AA228377848493927-1>")
    objEmail.Configuration.Fields.Update
    objEmail.Send
    
    
    '==========================================
    '
    'Search for an Active Sync Folder
    '
    '
    
    
    sub SerachAsync(furl)
    strQuery = "<?xml version=""1.0""?><D:searchrequest xmlns:D = ""DAV:"" >"
    strQuery = strQuery & "<D:sql>SELECT ""http://schemas.microsoft.com/mapi/proptag/x3001001E"""
    strQuery = strQuery & " FROM scope('shallow traversal of """
    strQuery = strQuery & furl & """') Where ""DAV:ishidden"" = False AND ""DAV:isfolder"" = True AND "
    strQuery = strQuery & """http://schemas.microsoft.com/mapi/proptag/x3001001E"" = 'Microsoft-Server-ActiveSync'</D:sql></D:searchrequest>"
    req.open "SEARCH", furl, false
    req.setrequestheader "Content-Type", "text/xml"
    req.setRequestHeader "Translate","f"
    on error resume next
    req.send strQuery
    if err.number <> 0 then wscript.echo err.description
    on error goto 0
    If req.status >= 500 Then
    ElseIf req.status = 207 Then
    	set oResponseDoc = req.responseXML
    	set oNodeList = oResponseDoc.getElementsByTagName("d:x3001001E")
    	if oNodeList.length <> 0 then
    		'wscript.echo "Active-Sync Folder Exists"
    		Devices = Devices + 1
    		displayAyncSub(furl & "/Microsoft-Server-ActiveSync")
    	else
    		'wscript.echo "No Active-Sync Folder"
    	end if 
    Else
    End If
    	
    end sub
    
    '==========================================
    '
    'Display an Active Sync Folder
    '
    '
    
    sub displayAyncSub(furl)
    
    strQuery = "<?xml version=""1.0""?><D:searchrequest xmlns:D = ""DAV:"" >"
    strQuery = strQuery & "<D:sql>SELECT ""http://schemas.microsoft.com/mapi/proptag/x3001001E"""
    strQuery = strQuery & " FROM scope('shallow traversal of """
    strQuery = strQuery & furl & """') Where ""DAV:ishidden"" = False AND ""DAV:isfolder"" = True</D:sql></D:searchrequest>"
    req.open "SEARCH", furl, false
    req.setrequestheader "Content-Type", "text/xml"
    req.setRequestHeader "Translate","f"
    on error resume next
    req.send strQuery
    if err.number <> 0 then wscript.echo err.description
    on error goto 0
    If req.status >= 500 Then
    ElseIf req.status = 207 Then
    	set oResponseDoc = req.responseXML
    	set oNodeList = oResponseDoc.getElementsByTagName("d:x3001001E")
    	for each node in oNodeList
    		call displaydeviceSub(furl & "/" & node.text,node.text)
    	next
    Else
    End If
    end sub
    
    
    
    
    '==========================================
    
    'Mark Extension Attributes for User
    
    '
    
    Sub SetExtAttributeInAD(strAttNum, strSAMAccountName, strInfo)
    On Error Resume Next
    	Dim objItem, objConnection, objCommand, objRootDSE, objRecordset
    	Dim strAttribute, strDNSDomain, strFilter, strQuery, strLDAP, strInputInfo
    
    	'Set ADODB connection to AD provider
    	Set objConnection = CreateObject("ADODB.Connection")
    	Set objCommand = CreateObject("ADODB.Command")
    	objConnection.Provider = "ADsDSOOBject"
    	objConnection.Open "Active Directory Provider"
    	Set objCommand.ActiveConnection = objConnection
    	'Build the query to execute.
    	strAttribute = "distinguishedName"
    	Set objRootDSE = GetObject("LDAP://RootDSE")
    	strDNSDomain = objRootDSE.Get("defaultNamingContext")
    	strFilter = "(&(sAMAccountName=" & strSAMAccountName & "))"
    	strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter & ";" & strAttribute & ";subtree"
    	'Initialize the query and set the recordset.
    	objCommand.CommandText = strQuery
    	objCommand.Properties("Page Size") = 100
    	objCommand.Properties("Timeout") = 30
    	objCommand.Properties("Cache Results") = False
    	Set objRecordSet = objCommand.Execute
    	'Retrieve the FQDN of the user name in AD.
    	strLDAP = objRecordSet(strAttribute)
    	'Connect to the AD user
    	Set objItem = GetObject("LDAP://" & strLDAP)
    	'Write the information to the Active Directory user's extensionAttribute
    	IsPopulated=objItem.Get("extensionAttribute1")
    	'
    	'
    	'
    	'If Extension Attribute1 isnt Populated, populate it 
    	'
    	'
    	'Comment this out if you do not want to mark a users extensionAttribute
    	'
    
    
    	if IsPopulated ="" then
    		objItem.Put "extensionAttribute" & strAttNum, strInfo
    		objItem.SetInfo
    	
    	else
    	'wscript.echo IsPopulated
    	end if
    End Sub
    
    
    
    '==========================================
    '
    'Create Report and Display for an Active Sync Users
    '
    '
    
    sub displaydeviceSub(furl,fname)
    
    strQuery = "<?xml version=""1.0""?><D:searchrequest xmlns:D = ""DAV:"" >"
    strQuery = strQuery & "<D:sql>SELECT ""http://schemas.microsoft.com/mapi/proptag/x3001001E"""
    strQuery = strQuery & " FROM scope('shallow traversal of """
    strQuery = strQuery & furl & """') Where ""DAV:ishidden"" = False AND ""DAV:isfolder"" = True</D:sql></D:searchrequest>"
    req.open "SEARCH", furl, false
    req.setrequestheader "Content-Type", "text/xml"
    req.setRequestHeader "Translate","f"
    on error resume next
    req.send strQuery
    if err.number <> 0 then wscript.echo err.description
    on error goto 0
    If req.status >= 500 Then
    ElseIf req.status = 207 Then
    	set oResponseDoc = req.responseXML
    	set oNodeList = oResponseDoc.getElementsByTagName("d:x3001001E")
    	'
    	'
    	'
    	'
    	'Only Choose "SmartPhone"Active Sync Devices for all replace line with  
    	'	if fname <>"" then
    	'
    	'
    	'
    	'
    	
    	if fname <>"" then
    	'wscript.echo fname
    	TotalDev=TotalDev+1
    	ReportUserName=rs1.fields("mailNickname")
    	'
    	'
    	'
    	'
    	'Populate Extension Attribute1 with motorolaq if it isnt already set for Dynamic DL to query on
    	'
    	'Comment this out if you do not want to mark a users extensionAttribute
    	'
    	'
    	'
    	SetExtAttributeInAD "1", ReportUserName, "motorolaq " & Now
    	for each node in oNodeList
    		report = report & "<tr>" & vbcrlf
    		report = report & "<td align=""center"">" & rs1.fields("displayname") & "&nbsp;</td>" & vbcrlf
    		report = report & "<td align=""center"">" & rs1.fields("mail") & "&nbsp;</td>" & vbcrlf
    		report = report & "<td align=""center"">" & fname & "&nbsp;</td>" & vbcrlf
    		report = report & "<td align=""center"">" & node.text  & "&nbsp;</td>" & vbcrlf
    		report = report & finditems(furl & "/" & node.text)
    		report = report & "</tr>" & vbcrlf
    		
    	next
    	Else
    	End If
    Else
    End If
    end sub
    
    function finditems(furl)
    
    hascalsyc = 0
    hasfolsyc = 0
    hasconsyc = 0
    hasautd = 0
    rback = ""
    strQuery = "<?xml version=""1.0""?><D:searchrequest xmlns:D = ""DAV:"" >"
    strQuery = strQuery & "<D:sql>SELECT ""DAV:displayname"", ""DAV:getlastmodified"""
    strQuery = strQuery & " FROM scope('shallow traversal of """
    strQuery = strQuery & furl & """') Where ""DAV:isfolder"" = False</D:sql></D:searchrequest>"
    req.open "SEARCH", furl, false
    req.setrequestheader "Content-Type", "text/xml"
    req.setRequestHeader "Translate","f"
    on error resume next
    req.send strQuery
    if err.number <> 0 then wscript.echo err.description
    on error goto 0
    rem wscript.echo req.responsetext
    If req.status >= 500 Then
    ElseIf req.status = 207 Then
    	set oResponseDoc = req.responseXML
    	set oNodeList = oResponseDoc.getElementsByTagName("a:displayname")
    	set oNodemodlist = oResponseDoc.getElementsByTagName("a:getlastmodified")
    	'wscript.echo oNodeList.length
    	for i = 1 to oNodeList.length
    		set onode = oNodeList.nextNode
    		set onode1 = oNodemodlist.nextNode
    		select case lcase(onode.text)
    			case "calendarsyncfile" hascalsyc = 1
    						hascalsycval = DateAdd("h",toffset,(left(replace(replace(onode1.text,"T"," "),"Z",""),19)))
    			case "foldersyncfile"	hasfolsyc = 1
    						hasfolsycval = DateAdd("h",toffset,(left(replace(replace(onode1.text,"T"," "),"Z",""),19)))
    			case "contactssyncfile" hasconsyc = 1
    						hasconsycval = DateAdd("h",toffset,(left(replace(replace(onode1.text,"T"," "),"Z",""),19)))
    			case "autdstate.xml"    hasautd = 1
    						hasautdval = DateAdd("h",toffset,(left(replace(replace(onode1.text,"T"," "),"Z",""),19)))
    		end select
    	next
    Else
    End If
    'wscript.echo hasfolsyc
    if hasfolsyc = 1  then
    	rback = rback & "<td align=""center"">" & hasfolsycval & "&nbsp;</td>" & vbcrlf
    else
    	rback = rback & "<td align=""center"">NoData&nbsp;</td>" & vbcrlf
    end if
    if hasautd  <> 0  then
    	rback = rback & "<td align=""center"">" & hasautdval & "&nbsp;</td>" & vbcrlf
    else
    	rback = rback & "<td align=""center"">NoData&nbsp;</td>" & vbcrlf
    end if
    finditems = rback
    end function
    
    
    

    terça-feira, 8 de maio de 2012 14:45
  • Thanks a ton .....works like a charm
    segunda-feira, 21 de maio de 2012 12:02
  • This was helpfull.  Is there another attribute for which Exchange server the device synced with?

    quarta-feira, 30 de maio de 2012 13:48
  • Try if this helps for E2K3...

    Using Log Parser to parse E2K3 front–end IIS logs to know mobile user hits: http://msexchangeguru.com/2012/06/08/e2k3-iis-log-parser/

    Get-CASMailbox -ResultSize unlimited -filter {HasActivesyncDevicePartnership -eq $True} | % {Get-ActiveSyncDeviceStatistics -Mailbox $_.identity} | ft Identity, DeviceType, DeviceID, DeviceUserAgent, LastSuccessSync >>.\Output.csv

    Exchange 2007 ActiveSync reporting: http://msexchangeguru.com/2010/05/20/e2k7-activesync-reporting

    sexta-feira, 8 de junho de 2012 13:59
  • Thank you! Simple and to the point. Just what I needed.
    quarta-feira, 17 de outubro de 2012 19:07
  • The above script is brilliant but if I am using | output-csv the export doesn't bring the export is the correct way. Is there any ways get the export in this way?

    Look forward to hear from you soon!!

    Thanks

    Ali


    Ali Hussaini

    sexta-feira, 21 de fevereiro de 2014 10:30
  • Below script will help in extracting active sync report Exchange ActiveSync - Report http://msexchange.me/2013/09/14/exchange-activesync-report/

    Sukhija Vikas

    domingo, 9 de março de 2014 04:21