Can we show the nested objects in Powershell?

I am adding a .NET type to Powershell session using Add-Type and then creating object of that type using New-Object. This is done as follows:
Add-Type -AssemblyName OuterObj
$a = New-Object OuterObj
Object of type OuterObj is successfully created. Now .NET type $a has a field named innerObj which is object of another .NET type innerObject. So I add "innerObject" .NET type and create an instance using New-Object.
Add-Type -AssemblyName innerObject
$b = New-Object innerObject
Object of type innerObject is also successfully created. Now I do as follows:
$a.innerObj = $b
Now when I print $a, it shows something like this:
innerObj : innerObject
Thus it does not display the contents of innerObject by default. When I go and explore, innerObj has the fields. I know Powershell does not show the nested objects by default but instead just shows their types, but is there a way I can specify that what
level of nesting of objects powershell should show by default? Is there something to specify to show 1 or 2 levels of nested objects?
Any help would be highly appreciated.

The simplest approach, if you're writing these C# classes yourself, is probably to override the class's ToString method.  That way it will just display that way by default in PowerShell, without any extra effort on the scripter's part.
If that's not an option, then you can write PowerShell code to accomplish something similar.  Here are examples of both:
# C# ToString version:
Add-Type -TypeDefinition @'
public class innerObject
public string Property1;
public string Property2;
public override string ToString()
return string.Format("Property1: {0}, Property2: {1}", Property1, Property2);
public class OuterObj
public innerObject innerObj;
$a = New-Object OuterObj
$b = New-Object innerObject -Property @{ Property1 = 'First Property'; Property2 = 'Second Property' }
$a.innerObj = $b
$a | Format-List
# PowerShell version using constructed property values with
# Format-List.
Add-Type -TypeDefinition @'
public class innerObject
public string Property1;
public string Property2;
public class OuterObj
public innerObject innerObj;
$a = New-Object OuterObj
$b = New-Object innerObject -Property @{ Property1 = 'First Property'; Property2 = 'Second Property' }
$a.innerObj = $b
$a | Format-List -Property @{ Label = 'innerObj'; Expression = { "Property1: $($_.innerObj.Property1), Property2: $($_.innerObj.Property2)" } }

Similar Messages

  • Can we show the root qualification group in tx PPPM & Matchup

    We have a requirement to show the root qualification group in PPPM and once the match up is done to also show the root object and not the direct parent qualification group.
    Is it possible to add another column in tx PPPM or to modify the content in an existing column.
    E.G. In the qualification catalog tx OOQA it displays as follows
    QK    Degrees
    -QK    BSC's
        -           Qual1
        -           Qual2
    -QK    BA's
        -           Qual3
    If i check on PPPM or on the screen after i have done the Profile match-up It reads as follows
    Qualification Group    Qualfiication
    BSC's                           Qual1
    BSC's                           Qual2
    BA's                             Qual3
    Their requirement is that it should show as follows:
    Qualification Group    Qualfiication
    Degrees                         Qual1
    Degrees                         Qual2
    Degrees                         Qual3
    Please assist if possible.

    Hi,
    You can copy and change the standard screen of the relevant subprofile.
    First goto SPRO - Personnel Management - Personnel development - Functions - Define profile view - Subprofiles.
    There find the report and screen of the subprofile - qualifications.
    Then you need the help of an ABAPer to copy the existing screen along with the function group -RHPP as far as I remember - and make the changes accordingly.
    Then you need to map the new screen to this subprofile.
    Regards,
    Dilek
    Edited by: Dilek Ersoz Adak on Jun 9, 2010 2:35 PM

  • How can I drop the java objects from a schema

    hi..good afternoon all...
    How can I drop the java objects from a database schema???
    suppose the credentials are scott/tiger@db1
    Another thing is that...I have to do this from cmd(command prompt) as there is no plsql developer or sqldeveloper installed in the machine.
    plss help...thanks in advance...

    hi...i have already tried all the options..but it is showing the error..
    ora:01435 - user does not exist
    but when i have given the command...
    select object type, object_name, status from user_objects where object_type like'%JAVA%';
    then it is showing that the java_object is present....
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    SQL>
    SQL>
    SQL> set linesize 200
    SQL>
    SQL>
    SQL>
    SQL> select object_type, object_name, status from user_objects where object_type
    like '%JAVA%';
    OBJECT_TYPE OBJECT_NAME
    STATUS
    JAVA CLASS javaclass1
    VALID
    JAVA SOURCE javaclass1
    VALID
    SQL> drop java source javaclass1.java;
    drop java source javaclass1.java
    ERROR at line 1:
    ORA-01435: user does not exist
    SQL>

  • How can i use the nested table in form 6i

    how can i use the nested table in the form 6i
    ( i.e i want to insert record into the nestred table field ).
    bye siddharth singh

    Nested tables are not supported in Forms 6i, only simple object tables.

  • How can I show the chart in forms?

    Dear all:
    I want to create a line chart. I use the chart wizard and it is successful to create the chart. But, it can't show the chart when I run the form. How can I show the chart in form6i?
    Besides, I see a document that refer to 'OG.pll'.
    I can't find the OG.pll in form6i. Do I need 'OG.pll' to show the chart when I run the form? Thank you very much!!

    Hi Carlos,
    You can try to create a code node for check which signature to print.
    In global variable declare a variable ie named g_sign type TDOBNAME.
    Then pass this var to name of graphics &g_sign&
    please check and reply.
    regards,

  • Can we cache the remote object?

    hi,
    can we cache the remote object?
    is this right way of doing?
    please suggest me
    regards
    crr

    Yes, caching EJBHome, EJBObject, and Remote business references is fine. They can also
    be portably stored in an HttpSession. However, when caching in the web tier you must still
    be careful to prevent concurrent access to the same stateful session bean. The fact that
    remote references to stateful session beans can be cached does not guarantee they can
    be accessed by more than one client at a time.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can LR show the numbers in Quick developement panel?

    Try to use quick development panel, it is easy to use but for exposure, clarity and vibrance you cannot see how many stops you have adjusted.
    Can LR show the numbers in Quick development panel?
    Any comment?

    >tt688 - 6:49am Sep 23, 08 PST (#2 of 6)
    >I think that Quick Deve function is useless if you can not see the how >many stops you have adjusted.
    When LR first came out I did not "get" the Quick Dev function. Luminous Landscape have an excellent video tutorial for LR by Michael Reichmann and Jeff Schewe.
    It explains that the QD function is there to allow you to make quick visual adjustments to images to assist in choosing picks / rejects and generally culling a shoot. Until you have the exposure / contrast / colour balance somewhere near correct, it is difficult to properly evaluate a shot. Using QD like this then makes sense, it's not supposed to duplicate or take the place of the develop module.
    Note that the adjustments you make in QD are relative, that is if you select a group of generally underexposed shots and increase the exposure the amount will be relative to each shots original exposure level.

  • SSDT Schema Compare keeps showing the same objects as different..

    Hi, 
    When comparing a database to my project using Visual Studio 2012 SSDT I get several stored procedures marked as changed. The body of the procedures is identical, but two properties are highlighted as different when expanding the object:
    IsSelf (false on the DB vs true on the project) and User  (dbo on the DB, needs to be added to the project).
    The procedures have the option "with execute as self" both in the database and in the project as part of the body.
    I have not found what needs to be done so these differences are applied to the project and never appear again. Tried changing some options on the schema compare but didn't found one that help. 
    Some forum suggested dropping the objects and re-creating them but I don't want to loose the history of changes on TFS.
    Any suggestions? 

    Hi Daniel,
    Since you have posted this issue to the SSDT forum here:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5c9c5c47-64ac-4af4-9104-c9500dc8cf52/ssdt-schema-compare-keeps-showing-the-same-objects-as-different?forum=ssdt#5c9c5c47-64ac-4af4-9104-c9500dc8cf52
    I will move this thread to the Off-topic forum, thanks for your understanding.
    Sincerely,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How can i show the first item in the list as selected item

    Aslam o Alikum (Hi)
    Dear All
    How can i show the first item in the list as selected item when user click on the list. Right now when user click the list the list shows the last item in the list as selected or highlighted. Furthermore if the list item have large no of value and a scroll bar along with it then the list scroll to last item when user click it with mouse. I want that when user click the list item with mouse list should show the first item as highlighted.
    Take Care
    Allah Hafiz

    Hi!
    You can set list "initial value" using When-Create-Record trigger.
    I.g.
    :<Block_name>.<list_item_name> := Get_List_Element_Value('<Block_name>.<list_item_name>', 1);

  • How can I show the photos of the person that im calling? now that im using IOS 7 when i want to call someone the photo /imagine does not appear , how can i fix it? iPhone 5, iOS 7

    how can I show the photos of the person that im calling? now that im using IOS 7 when i want to call someone the photo /imagine does not appear , how can i fix it?
    iPhone 5, iOS 7

    jlfcba wrote:
    IOS 7.1.1 doesn't show a "days to sync" parameter anywhere in SETTINGS/Mail,Contacts,Calendars/ACCOUNTS/GMAIL Account/ GMAIL Acccount Info.  There is nothing in iTunes relating to such an option either.  So, it seems I'm back to square one.
    If you have a decent mail provider like Microsoft Hotmail or Outlook.com mail it does.
    If you have Gmail it does not.  Quite right. Gmail is rubbish.

  • Can I know the automation object for firefox like "InternetExplorer.Application" for IE?

    Can I know the automation object for firefox like "InternetExplorer.Application" for IE?

    Firefox is not a COM-based application, so there is no equivalent. Over the years, different approaches have been offered for automating or embedding Firefox. The current one is [https://developer.mozilla.org/en/XULRunner XULRunner].

  • Can I operate the view object outside application module?

    I publish a Application Module into Oracle 8i Server. When I operate the view object in a class that published in Oracle 8i Server.
    It raise a remoteException. Can I operate the view object outside application module?

    Hi,
    The application module is the main point of contact for the ViewObject and EntityObject classes. It handles things like the connection pooling and other coordination aspects.
    You need to go through the app module to access the ViewObject class methods.

  • Web publishing tool, I can't show the panel in embedded mode.

    I don't know what happen but I have try every thing and still without the possibility to make a preview of my VI in the "web publishing tool" and also can't show the panel in embedded mode.
    I can see the preview in the browser but it remain forever "downloading panel" and nothing more else happen.
    Please help me because I don't find any explanation to this problem in Google.
    Additional information:
    1) I am using Labview professional development system 8.2 under Windows XP SP3 (it was the same under SP2), also in vista ultimate.
    2) In the attachment I show that I'm using Mozilla Firefox but is the same problem under IE.

    I don't think the preview ever shown an image.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • I am a Taiwanese. My iPod nano can not show the lyrics

    My iPod nan can not show the lyrics.It will be like"ifhfjdghuiadhghjkbdbdjkbdgdnkjn589d567g564h54df+.......................... "
    Why?
    How to solve it?

    Right->click on these tracks in iTunes and choose Get Info.  Then head to Lyrics tab.  Are the correct lyrics listed there?
    B-rock

  • Jsp include can not show the full page

    When i use jsp to include other jsp which have around 1000 lines. the included jsu can only show the last 500 lines. how can i solve lt?

    Having JSPs of this size is very bad practice. You should design your solution so as to avoid this at all costs.
    There is an upper size limit on JSPs which you may be running into here, check the JSP spec but it's something like 64k
    Regards,
    Gareth
    (PDK team)

Maybe you are looking for

  • Creating ERP Sales order with reference to CRM Service Order

    Hello all, I am trying to create an ERP Sales Order from CRM. If Icreate the Sales Order manually, it is working correctly but, if I try to create the ERP Sales Order as follow-up document for the CRM Service Order, it is not working. I have defined

  • How to install examples?

    There are supposed to be some example databases that are used with some tutorial that are in the same download directory as the zip files for Oracle 11g. So I finally have sqldeveloper connecting to the new instance of the database. When I try to run

  • Spitting out "phantom" cd's

    I have a MBP and for the most part, everything is working fine... with one very noticeable exception. For some bizarre reason, the cd eject sequence will run every few minutes. It's not a predictable thing and I have not noticed any pattern. Every 10

  • Flash CS5.5 and Android: Could not find an Android device to connect to...

    I am trying to deploy/debug an application from CS5.5 to an ASUS Transformer TF300 Tablet.  Every time I publish in Flash Pro I get the following error: "Could not find an Android device to connect to. Please ensure that you have a device connected,

  • Shared/lib folder is missing inTomcat

    Dear Experts, I have installed prerequisites for Integration Kit for SAP. 1)In the process of installing BO Integration Kit for SAP Solutions  i didnt find C:\Program Files\Business Objects\Tomcat55\Shared\lib to copy the file sapjco.jar.I observed o