PoshCode Archive  Artifact [156626f086]

Artifact 156626f0866d1d4cd499feab8772f2bbae50f51ed816c71bd9e9b2e836c76ccc:

  • File 20498039475807687.ps1 — part of check-in [fa805a7956] at 2018-06-10 13:32:11 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: 1268)

# encoding: utf-8
# api: powershell
# title: 20498039475807687
# 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: 3852
# x-derived-from-id: 3917
# x-archived: 2015-03-27T02:24:22
# x-published: 2015-12-31T23:49: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}