Nested Foreach in PowerShell

Welcome Forums General PowerShell Q&A Nested Foreach in PowerShell

Viewing 2 reply threads
  • Author
    Posts
    • #246087
      Participant
      Topics: 3
      Replies: 1
      Points: 30
      Rank: Member

      Hi All,

       

      I am training my power shell skiils and challenging my abilities, i need you assist with the following easy task.

       

      I want to get any VM and his own cluster on PowerCLI.

       

      I know that i can get this details using HOST.PARENT but i insist to get this details via “Cluster” in order to learn work with two for each, for some reason it doesn’t work for me, can you assist?

       

      • This topic was modified 1 month, 2 weeks ago by kvprasoon. Reason: Edited the title
    • #246207
      Participant
      Topics: 8
      Replies: 565
      Points: 2,157
      Helping Hand
      Rank: Community Hero

      I’m not sure your code is doing anything other than combining all VMs with all clusters. Maybe this is what you’re looking for?

      [/crayon]
    • #246423
      Participant
      Topics: 0
      Replies: 81
      Points: 362
      Helping Hand
      Rank: Contributor

      If you want to find the VMs within each cluster, you can the following with calculated properties:

Viewing 2 reply threads
  • You must be logged in to reply to this topic.