Вопрос

I apologize in advance as I am still fairly new to powershell. I'm figuring things out as I go, but this specific issue is stumping me. Currently this is with powershell 2.0 on exchange 2007.

I am trying to add to a script that I have been writing up that shows the basic information for our exchange accounts. This is just a small tool to be introduced to our help desk to assist in a quick overview of what is going on with a user's account. I have everything working, however, I want to change what is displayed. For example, I have:

Get-Mailbox $username | ft @{label="Hidden from GAL"; expression=    {$_.HiddenFromAddressListsEnabled}}, @{label="Restricted Delivery"; expression={$_.AcceptMessagesOnlyFrom}} -auto | out-string;

Which ends up returning true/false for hidden from address list, but for Accept Messages, if it is disabled, it returns "{}" (without quotes). If it is enabled, it displays the full group name (along the lines of admin.local/groupname). I only want to change {} to disabled, and instead of showing the group name, just show "enabled"

I tried an if/then statement, and then tried putting the variable "messRestrict" in the expression for accept messages above, and then the function name, but neither worked. They just returned blank values or always said "true." Here is the function:

function restricted {
$accept = Get-Mailbox $username |  AcceptMessagesOnlyFrom | select -expand Priority
#if ($accept -match "\s")
  #{$messRestrict="False"};
#else
  #{$messRestrict="True"};
}

The output is the standard Get-Mailbox output, I just want to replace what it says under the header.

Thanks!

Это было полезно?

Решение

You can try this :

@{label="Restricted Delivery"; expression={if($_.AcceptMessagesOnlyFrom){"Enabled"}else{"Disabled"}}}

It gives :

Get-Mailbox $username | ft @{label="Hidden from GAL"; expression=    {$_.HiddenFromAddressListsEnabled}}, @{label="Restricted Delivery"; expression={if($_.AcceptMessagesOnlyFrom){"Enabled"}else{"Disabled"}}} -auto | out-string;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top