سؤال

I am searching a specific OU, then disabling OWA for all users in the OU. This script runs daily.

I have the following script that works properly but is updating ALL the users in the OU.

$OU='OU=SomeOU,DC=Domain,DC=com'
$ext14='00254'
Get-Mailbox -OrganizationalUnit $OU| Where {$_.CustomAttribute14 -eq $ext14} | Set-CASMailbox -OWAEnabled:$false

I would like to ONLY update users that -OWAEnabled is set to $True (and change to $false) in this OU and sub OUs. This would reduce my calls to Exchange. Unfortunately, Set-CASMailbox does not seem to have an OU or CustomAttribute property to query against.

Any suggestions??

هل كانت مفيدة؟

المحلول

The CASMailbox object does not have the OU or CustomAttribute properties, but the Mailbox object does have protocolsettings property collection, so:

$OU='OU=SomeOU,DC=Domain,DC=com'
$ext14='00254'
Get-Mailbox -OrganizationalUnit $OU|
Where {($_.CustomAttribute14 -eq $ext14) -and ($_.protocolsettings -match 'OWA.1'} |
Set-CASMailbox -OWAEnabled:$false

نصائح أخرى

Try this:

Get-CASMailbox -OrganizationalUnit $OU | ? {
  $_.CustomAttribute14 -eq $ext14 -and $_.OWAEnabled
} | % {
  Set-CASMailbox -Identity $_.Identity -OWAEnabled:$false
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top