This could be a dumb question but nevertheless I am struggling to find the relevant information for this online and intellisense can only offer so much.
Below is some code I have quickly produced:
$upn = Get-Mailbox | Select-Object {$_.Alias}
$string = ":\Calendar"
foreach($_ in $upn)
{
$alias = $_
$Buffer = @();
$Buffer += '{0}' -f $alias;
Write-Host $Buffer
}
The results from the buffer output are as follows:
@{Alias=Test00}
@{Alias=Test01}
@{Alias=Test02}
@{Alias=Test03}
@{Alias=Test04}
When in fact, I want it to output like follows:
Test00
Test01
Test02
Test03
Test04
In all honesty I have had this occur to me in the past but wrote alternative solutions to work around it. I have come to the realization I can't and so I need to learn this and find out why the output displays @{}
?
I have tried selecting the column header by Name rather than the variable (Alias instead of {$_.Alias})
Also tried printing out the variable $_
and these results are identical to putting the variables into a formatted array.
Where am I going wrong?