PoshCode Archive  Artifact Content

Artifact a34f89d1d768b9ad681ab10e67f3eed141d0142cd7ece5d158f904de81912c3b:

  • File Set-Active-Sync-DeviceID.ps1 — part of check-in [0023bf94e6] at 2018-06-10 13:26:46 on branch trunk — Get DeviceID of all ActiveSync Devices for all Mailboxes with an ActiveSync partnership, then set the Mailboxes ActiveSyncAllowedDeviceIDs to the retrieved DeviceID. (user: thomas torggler size: 1277)

# encoding: utf-8
# api: powershell
# title: Set Active Sync DeviceID
# description: Get DeviceID of all ActiveSync Devices for all Mailboxes with an ActiveSync partnership, then set the Mailboxes ActiveSyncAllowedDeviceIDs to the retrieved DeviceID.
# version: 0.1
# author: thomas torggler
# license: CC0
# x-poshcode-id: 3507
# x-derived-from-id: 3508
# x-archived: 2015-03-27T01:33:33
# x-published: 2015-07-09T11:53:00
#
#
# Requires a connection to Exchange Server, or Exchange Management Shell

$s = New-PSSession -ConfigurationName Microsoft.Exchange -Name ExchMgmt -ConnectionUri http://ex14.domain.local/PowerShell/ -Authentication Kerberos
Import-PSSession $s

# Get all Client Access Server properties for all mailboxes with an ActiveSync Device Partnership
$Mailboxes = Get-CASMailbox -Filter {HasActivesyncDevicePartnership -eq $true} -ResultSize Unlimited

# Get DeviceID for all mailboxes
$EASMailboxes = $Mailboxes | Select-Object PrimarySmtpAddress,@{N='DeviceID';E={Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity | Select-Object –ExpandProperty DeviceID}}

# Set the ActiveSyncAllowedDeviceIDs attribute of all Mailboxes
$EASMailboxes | foreach {Set-CASMailbox $_.PrimarySmtpAddress -ActiveSyncAllowedDeviceIDs $_.DeviceID}