Hi,
Newish to Powershell so pardon anything that isn’t worded just right.
I’m running a powershell script against o365 and trying to switch the way it is done but the arrays seem to produce different outputs.
Running this returns all email address for users in our tenant and loads them into $the.
$the = Get-Recipient -ResultSize unlimited | select emailaddresses
If I do $the.emailaddresses it will split each emailaddress and display it 1 per line.
Due to the volume of items returned this command seems to return inconsistent results.
So I switched it up to the command below, which works fine and produces a text file.
Invoke-Command -Session(Get-PSSession) -scriptblock {Get-Recipient -ResultSize unlimited | Select-Object emailaddresses } | select emailaddresses | out-file -Append .\rawlog.txt
If I then run the command below I get the contents of the text file in a variable
$the1 = Get-Content .\rawlog.txt
If I view the contents of $the or $the1 in the console they appear to be the same data and look the same. Though I am unable to enter $the1.emailaddresses, it does not work and I get $null output. I’ve also noticed that $the.getvalue(3) returns the header (Emailaddresses) and the data that is in line 3 but does not count the header lines.
EmailAddresses
--------------
{smtp:xxxxx@Nxxxxx, smtp:xxxxx@xxxx, smtp:xxxx@jxxxx, smtp:xxxxx@xxxx…}
Where $the1.getvalue(3) returns the data in line 3 but includes the header lines countable lines.
{smtp:yyyyyy@Nyyyyy, smtp:yyyy@yyyyy, smtp:yyyyy@jyyyyy, smtp:yyyyyy@yyyy…}
Hopefully that makes sense.
Either way I am missing some piece of information about the array and the data contained within it. If I can provide further information let me know.
Jon