1

Question: I have an apparently simple PowerShell System Object that I am having a hard time selecting data from. Can somebody please help explain how I can select / expand the fields in this object?

More info:

I have selected an object (Public Folder) from my Exchange Online environment using

Get-MailPublicfolder

Now the object is stored in a variable $pf

$pf.getType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     ArrayList                                System.Object

When I do this

$pf | fl * 

I get the following output

EmailAddressPolicyEnabled              : False
PrimarySmtpAddress                     : metrowest@company.com
RecipientType                          : PublicFolder
RecipientTypeDetails                   : PublicFolder
DisplayName                            : Metro West

and so on.

However if I do this

$pf.displayName

or

$pf | select displayName

I get nothing back

When I do this

$pf | select * 


ClassId2e4f51ef21dd47e99d3c952918aff9cd : 033ecb2bc07a4d43b5ef94ed5a35d280
pageHeaderEntry                         :
pageFooterEntry                         :
autosizeInfo                            :
shapeInfo                               : Microsoft.PowerShell.Commands.Internal.Format.ListViewHeaderInfo
groupingEntry                           :

ClassId2e4f51ef21dd47e99d3c952918aff9cd : 9e210fe47d09416682b841769c78b8a3
shapeInfo                               :
groupingEntry                           :

ClassId2e4f51ef21dd47e99d3c952918aff9cd : 27c87ef9bbda4f709f6b4002fa4af63c
formatEntryInfo                         : Microsoft.PowerShell.Commands.Internal.Format.ListViewEntry
outOfBand                               : False
writeStream                             : None

ClassId2e4f51ef21dd47e99d3c952918aff9cd : 4ec4f0187cb04f4cb6973460dfe252df
groupingEntry                           :

ClassId2e4f51ef21dd47e99d3c952918aff9cd : cf522b78d86c486691226b40aa69e95c
groupingEntry                           :

and this

$pf | gm 


   TypeName: Microsoft.PowerShell.Commands.Internal.Format.FormatStartData

Name                                    MemberType Definition
----                                    ---------- ----------
Equals                                  Method     bool Equals(System.Object obj)
GetHashCode                             Method     int GetHashCode()
GetType                                 Method     type GetType()
ToString                                Method     string ToString()
autosizeInfo                            Property   Microsoft.PowerShell.Commands.Internal.Format.AutosizeInfo, System.Managem...
ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21dd47e99d3c952918aff9cd {get;}
groupingEntry                           Property   Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry, System.Manage...
pageFooterEntry                         Property   Microsoft.PowerShell.Commands.Internal.Format.PageFooterEntry, System.Mana...
pageHeaderEntry                         Property   Microsoft.PowerShell.Commands.Internal.Format.PageHeaderEntry, System.Mana...
shapeInfo                               Property   Microsoft.PowerShell.Commands.Internal.Format.ShapeInfo, System.Management...


   TypeName: Microsoft.PowerShell.Commands.Internal.Format.GroupStartData

Name                                    MemberType Definition
----                                    ---------- ----------
Equals                                  Method     bool Equals(System.Object obj)
GetHashCode                             Method     int GetHashCode()
GetType                                 Method     type GetType()
ToString                                Method     string ToString()
ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21dd47e99d3c952918aff9cd {get;}
groupingEntry                           Property   Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry, System.Manage...
shapeInfo                               Property   Microsoft.PowerShell.Commands.Internal.Format.ShapeInfo, System.Management...


   TypeName: Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData

Name                                    MemberType Definition
----                                    ---------- ----------
Equals                                  Method     bool Equals(System.Object obj)
GetHashCode                             Method     int GetHashCode()
GetType                                 Method     type GetType()
ToString                                Method     string ToString()
ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21dd47e99d3c952918aff9cd {get;}
formatEntryInfo                         Property   Microsoft.PowerShell.Commands.Internal.Format.FormatEntryInfo, System.Mana...
outOfBand                               Property   bool outOfBand {get;set;}
writeStream                             Property   Microsoft.PowerShell.Commands.Internal.Format.WriteStreamType, System.Mana...


   TypeName: Microsoft.PowerShell.Commands.Internal.Format.GroupEndData

Name                                    MemberType Definition
----                                    ---------- ----------
Equals                                  Method     bool Equals(System.Object obj)
GetHashCode                             Method     int GetHashCode()
GetType                                 Method     type GetType()
ToString                                Method     string ToString()
ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21dd47e99d3c952918aff9cd {get;}
groupingEntry                           Property   Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry, System.Manage...


   TypeName: Microsoft.PowerShell.Commands.Internal.Format.FormatEndData

Name                                    MemberType Definition
----                                    ---------- ----------
Equals                                  Method     bool Equals(System.Object obj)
GetHashCode                             Method     int GetHashCode()
GetType                                 Method     type GetType()
ToString                                Method     string ToString()
ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21dd47e99d3c952918aff9cd {get;}
groupingEntry                           Property   Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry, System.Manage...
Jon
  • 35
  • 5

2 Answers2

3

Do this:

$pf = Get-MailPublicfolder

Don't do this:

$pf = Get-MailPublicfolder | fl
# or
$pf = Get-MailPublicfolder | Format-List

Why? When you pass the results to Format-List, you end up with a formatted string object, instead of the MailPublicFolder returned by Get-MailPublicfolder. That's why you've seeing those members when running gm.

You can test if out by doing this, and this object will have the same members

$a = Get-ChildItem | Format-List
$a | Get-Member
G42
  • 196
  • 4
  • Thanks. Looks like it was just an oversight, I didn't realise I had done that when I was creating the object. – Jon Aug 09 '19 at 00:00
1

I test on my side, everything works fine. enter image description here

Jayce
  • 769
  • 4
  • 5