locked
[Exchange 2010] [PowerShell] HasActivesyncDevicePartnership doesn't reflect actually having device partnership? RRS feed

  • Question

  • I have discovered that in our environment, running

    (Get-CASMailbox -ResultSize Unlimited -Filter {HasActivesyncDevicePartnership -eq $true}).Count


    Results in the answer "233".  However, if I do this:

    $HasDevicePartnerships = Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $true}
    $MailboxWithActiveSyncDevice = @()
    ForEach ($Mailbox in $HasDevicePartnerships) {If (Get-ActiveSyncDevice -Mailbox $Mailbox.Name) {$MailboxWithActiveSyncDevice += $Mailbox}}
    $MailboxWithActiveSyncDevice.Count

    ...I only receive an answer of "223", which is 10 less than have the HasActiveSyncDevicePartnership flag set to $true.  What is the explanation for this?  I've seen people report that all of their user mailboxes have the HasActiveSyncDevicePartnership flags set to $true, but that is not true here as we have over 1800 user mailboxes.

    I see that when you connect an ActiveSync device to a user's mailbox that didn't previously have one that the HasActiveSyncDevicePartnership flag sets to $true.  Conversely when you do "Remove-ActiveSyncDevice -Identity <identity of an ActiveSync device>" and this removes the last ActiveSync device from a mailbox, then the HasActiveSyncDevicePartnership flag flips back to $false.

    So in what cases would HasActiveSyncDevicePartnership be set to $true but there be no actual ActiveSync devices attached to the mailbox, keeping in mind that no one in our organization has manually set this flag on any mailbox?



    • Edited by Scott W. Sander Thursday, March 1, 2012 7:37 PM Incorrect variable listed in code.
    Thursday, March 1, 2012 7:32 PM

Answers

  • On Tue, 6 Mar 2012 13:24:02 +0000, Scott W. Sander wrote:
     
    >(Get-Mailbox -ResultSize Unlimited).Count
    >
    >1803 (Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $false}).Count
    >
    >1571 (Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $true}).Count
    >
    >232 1571 + 232
    >
    >1803 $MailboxesWithActiveSyncDevice = @()
    >ForEach ($Mailbox in (Get-Mailbox -ResultSize Unlimited)) {If (Get-ActiveSyncDevice -Mailbox $Mailbox.Name) {$MailboxesWithActiveSyncDevice += $Mailbox}}
    >$MailboxesWithActiveSyncDevice.Count
    >
    >234
    >
    >I'm not sure what you are getting at here regarding looking at the results when checking for HasActiveSyncDevicePartnership set to $false. The number of mailboxes that have the flag set to $false plus the number set to $true equals the total number of mailboxes, as I'd expect. Therefore it is just as useless. But 234 and 232 are really close, right? That's true; however, not only is it still not accurate, but look at the results of the following code: $HasDevicePartnerships = Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $true}
    >$MailboxesWithActiveSyncDevice = @()
    >ForEach ($Mailbox in $HasDevicePartnerships) {If (Get-ActiveSyncDevice -Mailbox $Mailbox.Name) {$MailboxesWithActiveSyncDevice += $Mailbox}}
    >$MailboxesWithActiveSyncDevice.Count
    >
    >222
    >
    >If you look at my code in the last example, it filters for devices that have HasActiveSyncDevicePartnership set to $true and then among those results counts the mailboxes that actually do have ActiveSync devices attached, and it only comes up with 222 out of the 232. Yet there are actually 234 mailboxes that have ActiveSync device partnerships. This means that 12 mailboxes have ActiveSync devices attached but have HasActiveSyncDevicePartnership set to $false. It also means that 10 mailboxes have HasActiveSyncDevicePartnership set to $true, yet do not have ActiveSync devices attached.
     
    When an ActiveSync device is removed from the set of partnerships on
    the mailbox I don't thing the "HasActiveSyncDevicePartnership" is
    reset if the last device has been removed. Have you used the
    remove-activsyncdevice cmdlet?
     
    When you're doing your "Get-CASMailbox" you should add '-and -not
    Displayname -like "CAS_{*"; to the filter.
     
    I've also seen this situation on mailboxes that have been around since
    Exchange 2003 or that have been moved from another organziation.
     
    You can try this bit of code (the "-Whatif" is set to $true so all
    it'll do is produce the CSV file. I took this from a posting earlier
    (I forget who the original author was -- sorry) and neatened it up a
    bit. If the results look good you can set -Whatif to $false and rerun
    it.
     
    $badASPartnerships = @()
    Get-Mailbox -ResultSize unlimited | foreach {
    $mbxldn = $_.LegacyExchangeDN
    $casmbx = Get-CASMailbox -Identity $mbxldn -ResultSize 1
    if($casmbx.HasActivesyncDevicePartnership -eq $true -and -not
    (Get-ActiveSyncDeviceStatistics -Mailbox $mbxldn) )
    {
    $badASPartnerships += $casmbx | select
    SamAccountName,DisplayName,activeSyncMailboxPolicy,WhenCreated,DistinguishedName
    $casmbx | Set-CASMailbox
    -HasActiveSyncDevicePartnership:$false -Whatif:$true
    }
    }
    $badASPartnerships | Export-Csv ProblemPartnerships.csv
    -NoTypeInformation
     
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    Tuesday, March 6, 2012 7:04 PM

All replies

  • On Thu, 1 Mar 2012 19:32:26 +0000, Scott W. Sander wrote:
     
    >
    >
    >I have discovered that in our environment, running (Get-CASMailbox -ResultSize Unlimited -Filter {HasActivesyncDevicePartnership -eq $true}).Count
    >
    >
    >
    >Results in the answer "233". However, if I do this:
    >
    >$HasDevicePartnerships = Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $true}
    >$MailboxWithActiveSyncDevice = @()
    >ForEach ($Mailbox in $HasDevicePartnerships) {If (Get-ActiveSyncDevice -Mailbox $Mailbox.Name) {$MailboxWithActiveSyncDevice += $Mailbox}}
    >$MailboxWithActiveSyncDevice.Count
    >
    >
    >
    >...I only receive an answer of "223", which is 10 less than have the HasActiveSyncDevicePartnership flag set to $true. What is the explanation for this? I've seen people report that all of their user mailboxes have the HasActiveSyncDevicePartnership flags set to $true, but that is not true here as we have over 1800 user mailboxes.
    >
    >I see that when you connect an ActiveSync device to a user's mailbox that didn't previously have one that the HasActiveSyncDevicePartnership flag sets to $true. Conversely when you do "Remove-ActiveSyncDevice -Identity <identity of an ActiveSync device>" and this removes the last ActiveSync device from a mailbox, then the HasActiveSyncDevicePartnership flag flips back to $false.
    >
    >So in what cases would HasActiveSyncDevicePartnership be set to $true but there be no actual ActiveSync devices attached to the mailbox, keeping in mind that no one in our organization has manually set this flag on any mailbox?
     
    If all of the device partnerships have been removed from the mailbox
    it would still pass the "HasActiveSyncDevicePartnership" test.
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    Friday, March 2, 2012 3:13 AM
  • Hi

    Did you try what Rich said?

    You can filter out those users who could not pass the command Get-ActiveSyncDevice

    And check their property in order to comfirm

    Cheers

    Zi Feng


    Zi Feng

    TechNet Community Support

    Monday, March 5, 2012 5:19 AM
    Moderator
  • In general I am having trouble understanding the HasActiveSyncDevicePartnership flag and what it really indicates.  I just took a test user account that is mail-enabled and verified that the HasActiveSyncDevicePartnership flag was set to $false, linked my Android device to the mailbox, waited a few minutes, and then ran Get-CASMailbox -Identity "Jane Doe" | Select-Object Name, HasActiveSyncDevicePartnership and that flag is still set to $false.

    I don't understand that. If I do Get-ActiveSyncDevice -Mailbox "Jane Doe", I see the device I just added, but the HasActiveSyncDevicePartnership flag is still set to false.  Also, I just ran these commands:

    $Mailboxes = Get-Mailbox -ResultSize Unlimited
    $MailboxesWithActiveSyncDevice = @()
    ForEach ($Mailbox in $Mailboxes) {If (Get-ActiveSyncDevice -Mailbox $Mailbox.Name) {$MailboxesWithActiveSyncDevice += $Mailbox}}
    $MailboxesWithActiveSyncDevice.Count

    ...and I got 236 as the result of the last command.  If I run the second sequence of commands from my original post I still get 223.  This means there are currently 13 mailboxes that have HasActiveSyncDevicePartnership set to $false but actually do have ActiveSync devices attached.

    What is the point of that flag if it doesn't represent reality?


    • Edited by Scott W. Sander Monday, March 5, 2012 2:21 PM More information added.
    Monday, March 5, 2012 1:47 PM
  • Hi

    How about run the command to Check how many mailboxes that HasActiveSyncDevicePartnership set to $false

    (Get-CASMailbox -ResultSize Unlimited -Filter {HasActivesyncDevicePartnership -eq $false}).count

    Cheers


    Zi Feng

    TechNet Community Support

    Tuesday, March 6, 2012 6:22 AM
    Moderator
  • (Get-Mailbox -ResultSize Unlimited).Count

    1803


    (Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $false}).Count

    1571


    (Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $true}).Count

    232


    1571 + 232

    1803


    $MailboxesWithActiveSyncDevice = @()
    ForEach ($Mailbox in (Get-Mailbox -ResultSize Unlimited)) {If (Get-ActiveSyncDevice -Mailbox $Mailbox.Name) {$MailboxesWithActiveSyncDevice += $Mailbox}}
    $MailboxesWithActiveSyncDevice.Count

    234


    I'm not sure what you are getting at here regarding looking at the results when checking for HasActiveSyncDevicePartnership set to $false.  The number of mailboxes that have the flag set to $false plus the number set to $true equals the total number of mailboxes, as I'd expect.  Therefore it is just as useless.  But 234 and 232 are really close, right?  That's true; however, not only is it still not accurate, but look at the results of the following code:

    $HasDevicePartnerships = Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $true}
    $MailboxesWithActiveSyncDevice = @()
    ForEach ($Mailbox in $HasDevicePartnerships) {If (Get-ActiveSyncDevice -Mailbox $Mailbox.Name) {$MailboxesWithActiveSyncDevice += $Mailbox}}
    $MailboxesWithActiveSyncDevice.Count

    222

    If you look at my code in the last example, it filters for devices that have HasActiveSyncDevicePartnership set to $true and then among those results counts the mailboxes that actually do have ActiveSync devices attached, and it only comes up with 222 out of the 232.  Yet there are actually 234 mailboxes that have ActiveSync device partnerships.  This means that 12 mailboxes have ActiveSync devices attached but have HasActiveSyncDevicePartnership set to $false.  It also means that 10 mailboxes have HasActiveSyncDevicePartnership set to $true, yet do not have ActiveSync devices attached.

    Tuesday, March 6, 2012 1:24 PM
  • On Tue, 6 Mar 2012 13:24:02 +0000, Scott W. Sander wrote:
     
    >(Get-Mailbox -ResultSize Unlimited).Count
    >
    >1803 (Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $false}).Count
    >
    >1571 (Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $true}).Count
    >
    >232 1571 + 232
    >
    >1803 $MailboxesWithActiveSyncDevice = @()
    >ForEach ($Mailbox in (Get-Mailbox -ResultSize Unlimited)) {If (Get-ActiveSyncDevice -Mailbox $Mailbox.Name) {$MailboxesWithActiveSyncDevice += $Mailbox}}
    >$MailboxesWithActiveSyncDevice.Count
    >
    >234
    >
    >I'm not sure what you are getting at here regarding looking at the results when checking for HasActiveSyncDevicePartnership set to $false. The number of mailboxes that have the flag set to $false plus the number set to $true equals the total number of mailboxes, as I'd expect. Therefore it is just as useless. But 234 and 232 are really close, right? That's true; however, not only is it still not accurate, but look at the results of the following code: $HasDevicePartnerships = Get-CASMailbox -ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $true}
    >$MailboxesWithActiveSyncDevice = @()
    >ForEach ($Mailbox in $HasDevicePartnerships) {If (Get-ActiveSyncDevice -Mailbox $Mailbox.Name) {$MailboxesWithActiveSyncDevice += $Mailbox}}
    >$MailboxesWithActiveSyncDevice.Count
    >
    >222
    >
    >If you look at my code in the last example, it filters for devices that have HasActiveSyncDevicePartnership set to $true and then among those results counts the mailboxes that actually do have ActiveSync devices attached, and it only comes up with 222 out of the 232. Yet there are actually 234 mailboxes that have ActiveSync device partnerships. This means that 12 mailboxes have ActiveSync devices attached but have HasActiveSyncDevicePartnership set to $false. It also means that 10 mailboxes have HasActiveSyncDevicePartnership set to $true, yet do not have ActiveSync devices attached.
     
    When an ActiveSync device is removed from the set of partnerships on
    the mailbox I don't thing the "HasActiveSyncDevicePartnership" is
    reset if the last device has been removed. Have you used the
    remove-activsyncdevice cmdlet?
     
    When you're doing your "Get-CASMailbox" you should add '-and -not
    Displayname -like "CAS_{*"; to the filter.
     
    I've also seen this situation on mailboxes that have been around since
    Exchange 2003 or that have been moved from another organziation.
     
    You can try this bit of code (the "-Whatif" is set to $true so all
    it'll do is produce the CSV file. I took this from a posting earlier
    (I forget who the original author was -- sorry) and neatened it up a
    bit. If the results look good you can set -Whatif to $false and rerun
    it.
     
    $badASPartnerships = @()
    Get-Mailbox -ResultSize unlimited | foreach {
    $mbxldn = $_.LegacyExchangeDN
    $casmbx = Get-CASMailbox -Identity $mbxldn -ResultSize 1
    if($casmbx.HasActivesyncDevicePartnership -eq $true -and -not
    (Get-ActiveSyncDeviceStatistics -Mailbox $mbxldn) )
    {
    $badASPartnerships += $casmbx | select
    SamAccountName,DisplayName,activeSyncMailboxPolicy,WhenCreated,DistinguishedName
    $casmbx | Set-CASMailbox
    -HasActiveSyncDevicePartnership:$false -Whatif:$true
    }
    }
    $badASPartnerships | Export-Csv ProblemPartnerships.csv
    -NoTypeInformation
     
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    Tuesday, March 6, 2012 7:04 PM
  • HI:

    I have experienced this same problem.  I have a powershell query that pulls mailbox data for only those user's that have activesync device partnerships established:

    Get-CASMailbox -ResultSize:Unlimited -filter HasActiveSyncDevicePartnership -eq $true'

    The filter relies on the accuracy of the HasActiveSyncDevicePartnership property on the mailbox.  I have seen this property with a value of "True" when there are no device partnerships and I have seen this property with a value of "False" when there are device partnerships present.  Very frustrating and it seems that this property cannot be relied upon to be accurate.  I have never seen this problem occur in an Exchange 2007 environment.  And, in fact have only seen this problem in Exchange 2010 when the DefaultAccessLevel Organization setting is "Quarantine".  Can someone at Microsoft please explain how this flag gets updated?  For me, it is an efficiency issue.  I don't want to include mailboxes in my query collection that do not have device partnerships.  Also, I really do not want to have to use a filter that relies on calling the Get-ActivesyncDeviceStatistics cmdlet to determine if a device partnership exists.  Bottom line is that the HasActiveSyncDevicePartnership property should be an accurate indicator.  Right now, unfortunately, it looks like this property is, in fact, inaccurate in some situations.


    • Edited by jclarkEXC Wednesday, May 23, 2012 7:28 PM
    Wednesday, May 23, 2012 7:27 PM
  • I have run into this - if you find a user that comes back with hasactivesyncdevicepartnership -eq $true, but you can't find any associated devices - go find that user object ADUC or ADSIEDIT, go to the attribute editor and clear the msExchMobileMailboxFlags attribute on that user(s).

    Wednesday, December 12, 2012 9:31 PM