PoshCode Archive  Artifact Content

Artifact fa98e534053f0cbc68557f9b0479c56df44cb9279d14fc30fb8d2ebbb8a62070:

  • File Set-Active-Sync-DeviceID.ps1 — part of check-in [59784c7271] at 2018-06-10 13:26:47 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: 1275)

# 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: 3508
# x-derived-from-id: 3852
# x-archived: 2015-05-04T21:42:47
# 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}