Domanda

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??

È stato utile?

Soluzione

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

Altri suggerimenti

Try this:

Get-CASMailbox -OrganizationalUnit $OU | ? {
  $_.CustomAttribute14 -eq $ext14 -and $_.OWAEnabled
} | % {
  Set-CASMailbox -Identity $_.Identity -OWAEnabled:$false
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top