PowerShell: Convert an object to a string
powershell
Solution
It is hard to tell if that could be optimized without seeing the second part...
But it's pretty easy to get a flat array of identities. Either use `-ExpandProperty` on select, or use `foreach { $_.Identity }` instead of select:
$allIS = Get-MailboxDatabase | ? { $_.name -notlike "*Users*" } | select -expand Identity
$allIS = Get-MailboxDatabase | ? { $_.Name -notlike '*Users*' | foreach { $_.Identity}
Problem
We have Exchange Info Stores that begin with UsersA-B, UsersC-D, etc., and then some that are outside that naming convention. ``` $allIS = Get-MailboxDatabase | Where { $_.name -notlike "*Users*" } | Select Identity ``` I'll lookup a current user's info store, and then try to do a comparison on the $allIS array. If it matches, do some action. When I output the value of $allIS[0] for instance, it returns `@{Identity=MSCCR\CEO\CEO}`. I'd like to throw those converted strings into a different array, and then do the comparison. This would be to have a dynamic list of information stores to compare against. But maybe this isn't the best, most efficient way. What would be the best way to try to do this comparison, as right now I'm comparing apples to oranges here?