Calling hash Table inside Calculated property issue?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 3 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ITEngineer
Posts: 216
Last visit: Thu Mar 23, 2023 5:45 pm
Has voted: 4 times

Calling hash Table inside Calculated property issue?

Post by ITEngineer »

Hi Folks,

I need some help to fix the one line which maps the values of a number to a string in this Hashtable.

Code: Select all

$mailboxType = @{
    "0"               = "UserMailbox"
    "1073741824"   = "Shared Mailbox"
    "6"               = "MailUser"
    "7"               = "Room"
    "8"               = "Equipment"
    "-2147483642"  = "RemoteUserMailbox"
    "-1073741818 " = "RemoteUserMailbox-Hybrid Delegate"
}

Get-MsolUser -All |
Where-Object { ($_.blockcredential -eq $true) -and ($_.isLicensed -eq $true) } |
Select-Object DisplayName,
              UserPrincipalName,
              @{ n = 'Mailbox Type'; e = { $mailboxType[$_.CloudExchangeRecipientDisplayType].GetEnumerator().Value.ToString() } },
              isLicensed,
              BlockCredential,
              Licenses,
              LicenseAssignmentDetails,
              WhenCreated | Format-Table -AutoSize
The script is working fine it is just the Hashtable calling is not working.

The problem is the column Mailbox Type is always empty. But when I just use the default CloudExchangeRecipientDisplayType, the column value is a meaningless decimal number like in https://cloudrun.co.uk/office365/recipi ... directory/

Thank you in advance
/* IT Engineer */
This topic is 3 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked