Assistance formatting a query in the Exchange Management Shell
I am writing a script to automatically disable OutlookAnywhere access for people who are not authorized. I have an A/D group set up for this. The line in my script I am having problems with is: Get-CASMailbox -resultsize unlimited | where {$_.MAPIBlockOutlookRpcHttp} What I want is the exact opposite of this. When I query this, it returns the people who have MAPIBlockOutlookRpcHttp set to true, I want it to return the people who have MAPIBlockOutlookRpcHttp set to false. I tried using -filter, but when I do it tells me that MapBlockOutlookRpcHttp doesn't work with the -filter [PS] C:\>Get-CASMailbox -resultsize unlimited -filter {MAPIBlockOutlookRpcHttp -eq $false} Get-CASMailbox : Cannot bind parameter 'Filter' to the target. Exception setting "Filter": ""MAPIBlockOutlookRpcHttp" is not a recognized filterable property. For a complete list of filterable properties see the command help. "MAPIBlockOutlookRpcHttp -eq $false" at position 1." At line:1 char:45 + Get-CASMailbox -resultsize unlimited -filter <<<< {MAPIBlockOutlookRpcHttp -eq $false} + CategoryInfo : WriteError: (:) [Get-CASMailbox], ParameterBindingException + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.Exchange.Management.RecipientTasks.GetCASMailbox I also thought something like Get-CASMailbox-resultsizeunlimited|wherenot({$_.MAPIBlockOutlookRpcHttp}) But that didn't work either. Thanks for any advice on how to write this. DarhlWe will never be an advanced civilization as long as rain showers can delay the launching of a space rocket. -George Carlin
March 3rd, 2011 11:20am

Here's the whole PowerShell script if anyone wants to see it #Set OutlookAnywhere access $AD4 = (get-group ‘Mail_OutlookAnywhere_Enabled’).members | select ObjectGuid | ForEach-Object {Get-User -Identity ([string]$_.ObjectGuid)} | select Name, DistinguishedName $EX4 = Get-CASMailbox -resultsize unlimited | where {$_.MAPIBlockOutlookRpcHttp} | select Name, DistinguishedName $EX4 | ForEach-Object {if (($AD4 | ForEach-Object {$_.DistinguishedName}) -notcontains $_.DistinguishedName) {Set-CASMailbox -identity $_.DistinguishedName -MAPIBlockOutlookRpcHttp $false}} $AD4 | ForEach-Object {if (($EX4 | ForEach-Object {$_.DistinguishedName}) -notcontains $_.DistinguishedName) {Set-CASMailbox -identity $_.DistinguishedName -MAPIBlockOutlookRpcHttp $true}} What it's supposed to do is enable MAPIBlockOutlookRpcHttp for everyone then disable it for those in the group. I have similar scripts that are working properly for POP3, IMAP, & ActiveSync, but the MAPIBlockOutlookRpcHttp value is opposite of the other three. For example, this ActiveSync script works as desired (aka disable ActiveSync for everyone then only enable it for those in the group). I do it this way so if there are adds/removes from the group, it handles these properly. I then schedule the script to run once an hour during the day so if any changes are made, it picks up the change within an hour. #Set ActiveSync access $AD3 = (get-group ‘Mail_ActiveSync_Enabled’).members | select ObjectGuid | ForEach-Object {Get-User -Identity ([string]$_.ObjectGuid)} | select Name, DistinguishedName $EX3 = Get-CASMailbox -resultsize unlimited | where {$_.ActiveSyncEnabled} | select Name, DistinguishedName $EX3 | ForEach-Object {if (($AD3 | ForEach-Object {$_.DistinguishedName}) -notcontains $_.DistinguishedName) {Set-CASMailbox -identity $_.DistinguishedName -ActiveSyncEnabled $false}} $AD3 | ForEach-Object {if (($EX3 | ForEach-Object {$_.DistinguishedName}) -notcontains $_.DistinguishedName) {Set-CASMailbox -identity $_.DistinguishedName -ActiveSyncEnabled $true}} Thanks again! d “We will never be an advanced civilization as long as rain showers can delay the launching of a space rocket.” -George Carlin
Free Windows Admin Tool Kit Click here and download it now
March 3rd, 2011 11:29am

What I want is the exact opposite of this. When I query this, it returns the people who have MAPIBlockOutlookRpcHttp set to true, I want it to return the people who have MAPIBlockOutlookRpcHttp set to false. Get-CASMailbox -resultsize unlimited | where {$_.MAPIBlockOutlookRpcHttp} Hi WithAnH, Please try to run Get-CASMailbox -resultsize unlimited | where {$_.MAPIBlockOutlookRpcHttp -eq 0}Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
March 8th, 2011 1:05am

Hi Frank, Looks like that did not work: [PS] C:\Windows\system32>Get-CASMailbox -resultsize unlimited | where {$_.MAPIBlockOutlookRpcHttp -eq 0} The term 'Get-CASMailbox -resultsize unlimited ' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try ag ain. At line:1 char:38 + Get-CASMailbox -resultsize unlimited <<<< | where {$_.MAPIBlockOutlookRpcHtt p -eq 0} + CategoryInfo : ObjectNotFound: (Get-CASMailbox -resultsize unli mited :String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException We will never be an advanced civilization as long as rain showers can delay the launching of a space rocket. -George Carlin
Free Windows Admin Tool Kit Click here and download it now
March 11th, 2011 6:34pm

The line in my script I am having problems with is: Get-CASMailbox -resultsize unlimited | where {$_.MAPIBlockOutlookRpcHttp} What I want is the exact opposite of this. When I query this, it returns the people who have MAPIBlockOutlookRpcHttp set to true, I want it to return the people who have MAPIBlockOutlookRpcHttp set to false. Hi WithAnH, You can run the cmdlet Get-CASMailbox -resultsize unlimited | where {$_.MAPIBlockOutlookRpcHttp} ago, but cannot run it with "-eq 0" now? Please make sure you have the right permission to run the cmdlet. Exchange 2007 or 2010? Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
March 13th, 2011 10:24pm

I do not believe it is a permissions error, if you look at the result I posted, it says: The term 'Get-CASMailbox -resultsize unlimited ' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try ag ain. I ran it again and the original cmdlet did not work either. I copied it from my original post and it did run. There must be a weird character embedded in the reply you left to cause it to not work. In any case, I copied my line from above and added "-eq 0" and believe it returned the result I was expecting. Thanks! We will never be an advanced civilization as long as rain showers can delay the launching of a space rocket. -George Carlin
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 10:04am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics