VMware, Output the Network HealthCheck in on CSV file












0















I have a script, it work perfectly and everything is show on my power shell screen "Console". But I try to figure Out how to export in CSV



Script:



foreach($vds in Get-VDSwitch)
{
$vds.ExtensionData.Runtime.HostMemberRuntime | %{
$.HealthCheckResult | where{$ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult]} |
Select @{N='vdSwitch';E={$vds.Name}},
UplinkPortKey,
@{N='TrunkedVLAN';E={
($.TrunkedVLAN | %{
if($
.Start -eq $.End){
"{0}" -f $
.Start
}
else{
"{0}-{1}" -f $.Start,$.End
}
}) -join ','

}}
}



}



The Output on screen look like this;



VsanEnabled : False
VsanDiskClaimMode : Manual
HATotalSlots : 3099
HAUsedSlots : 22
HAAvailableSlots : 1527
HASlotCpuMHz : 32
HASlotMemoryMb : 328
HASlotMemoryGB : 0.3203125
HASlotNumVCpus : 1
ParentId : Folder-group-h28
ParentFolder : host
HAEnabled : True
HAAdmissionControlEnabled : True
HAFailoverLevel : 1
HARestartPriority : Medium
HAIsolationResponse : DoNothing
VMSwapfilePolicy : WithVM
DrsEnabled : True
DrsMode : FullyAutomated
DrsAutomationLevel : FullyAutomated
EVCMode : intel-nehalem
Name : mac01dmzp01
CustomFields : {}
ExtensionData : VMware.Vim.ClusterComputeResource
Id : ClusterComputeResource-domain-c12033
Uid : /VIServer=cnt175726@mac01vcp02.cn.ca:443/Cluster=ClusterComputeResource-domain-c12033/



vdSwitch : vds-toronto-mac01-2-ports-10Gbe
UplinkPortKey : 78
TrunkedVLAN : 11-17,396,500



vdSwitch : vds-toronto-mac01-2-ports-10Gbe
UplinkPortKey : 79
TrunkedVLAN : 11-17,396,500



vdSwitch : vds-toronto-mac01-2-ports-10Gbe
UplinkPortKey : 82
TrunkedVLAN : 11-17,396,500



vdSwitch : vds-toronto-mac01-2-ports-10Gbe
UplinkPortKey : 83
TrunkedVLAN : 11-17,396,500



vdSwitch : vds-toronto-mac01-2-ports-10Gbe
UplinkPortKey : 358
TrunkedVLAN : 11-17,396,500



vdSwitch : vds-toronto-mac01-2-ports-10Gbe
UplinkPortKey : 359
TrunkedVLAN : 11-17,396,500



a lot more ......










share|improve this question





























    0















    I have a script, it work perfectly and everything is show on my power shell screen "Console". But I try to figure Out how to export in CSV



    Script:



    foreach($vds in Get-VDSwitch)
    {
    $vds.ExtensionData.Runtime.HostMemberRuntime | %{
    $.HealthCheckResult | where{$ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult]} |
    Select @{N='vdSwitch';E={$vds.Name}},
    UplinkPortKey,
    @{N='TrunkedVLAN';E={
    ($.TrunkedVLAN | %{
    if($
    .Start -eq $.End){
    "{0}" -f $
    .Start
    }
    else{
    "{0}-{1}" -f $.Start,$.End
    }
    }) -join ','

    }}
    }



    }



    The Output on screen look like this;



    VsanEnabled : False
    VsanDiskClaimMode : Manual
    HATotalSlots : 3099
    HAUsedSlots : 22
    HAAvailableSlots : 1527
    HASlotCpuMHz : 32
    HASlotMemoryMb : 328
    HASlotMemoryGB : 0.3203125
    HASlotNumVCpus : 1
    ParentId : Folder-group-h28
    ParentFolder : host
    HAEnabled : True
    HAAdmissionControlEnabled : True
    HAFailoverLevel : 1
    HARestartPriority : Medium
    HAIsolationResponse : DoNothing
    VMSwapfilePolicy : WithVM
    DrsEnabled : True
    DrsMode : FullyAutomated
    DrsAutomationLevel : FullyAutomated
    EVCMode : intel-nehalem
    Name : mac01dmzp01
    CustomFields : {}
    ExtensionData : VMware.Vim.ClusterComputeResource
    Id : ClusterComputeResource-domain-c12033
    Uid : /VIServer=cnt175726@mac01vcp02.cn.ca:443/Cluster=ClusterComputeResource-domain-c12033/



    vdSwitch : vds-toronto-mac01-2-ports-10Gbe
    UplinkPortKey : 78
    TrunkedVLAN : 11-17,396,500



    vdSwitch : vds-toronto-mac01-2-ports-10Gbe
    UplinkPortKey : 79
    TrunkedVLAN : 11-17,396,500



    vdSwitch : vds-toronto-mac01-2-ports-10Gbe
    UplinkPortKey : 82
    TrunkedVLAN : 11-17,396,500



    vdSwitch : vds-toronto-mac01-2-ports-10Gbe
    UplinkPortKey : 83
    TrunkedVLAN : 11-17,396,500



    vdSwitch : vds-toronto-mac01-2-ports-10Gbe
    UplinkPortKey : 358
    TrunkedVLAN : 11-17,396,500



    vdSwitch : vds-toronto-mac01-2-ports-10Gbe
    UplinkPortKey : 359
    TrunkedVLAN : 11-17,396,500



    a lot more ......










    share|improve this question



























      0












      0








      0








      I have a script, it work perfectly and everything is show on my power shell screen "Console". But I try to figure Out how to export in CSV



      Script:



      foreach($vds in Get-VDSwitch)
      {
      $vds.ExtensionData.Runtime.HostMemberRuntime | %{
      $.HealthCheckResult | where{$ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult]} |
      Select @{N='vdSwitch';E={$vds.Name}},
      UplinkPortKey,
      @{N='TrunkedVLAN';E={
      ($.TrunkedVLAN | %{
      if($
      .Start -eq $.End){
      "{0}" -f $
      .Start
      }
      else{
      "{0}-{1}" -f $.Start,$.End
      }
      }) -join ','

      }}
      }



      }



      The Output on screen look like this;



      VsanEnabled : False
      VsanDiskClaimMode : Manual
      HATotalSlots : 3099
      HAUsedSlots : 22
      HAAvailableSlots : 1527
      HASlotCpuMHz : 32
      HASlotMemoryMb : 328
      HASlotMemoryGB : 0.3203125
      HASlotNumVCpus : 1
      ParentId : Folder-group-h28
      ParentFolder : host
      HAEnabled : True
      HAAdmissionControlEnabled : True
      HAFailoverLevel : 1
      HARestartPriority : Medium
      HAIsolationResponse : DoNothing
      VMSwapfilePolicy : WithVM
      DrsEnabled : True
      DrsMode : FullyAutomated
      DrsAutomationLevel : FullyAutomated
      EVCMode : intel-nehalem
      Name : mac01dmzp01
      CustomFields : {}
      ExtensionData : VMware.Vim.ClusterComputeResource
      Id : ClusterComputeResource-domain-c12033
      Uid : /VIServer=cnt175726@mac01vcp02.cn.ca:443/Cluster=ClusterComputeResource-domain-c12033/



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 78
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 79
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 82
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 83
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 358
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 359
      TrunkedVLAN : 11-17,396,500



      a lot more ......










      share|improve this question
















      I have a script, it work perfectly and everything is show on my power shell screen "Console". But I try to figure Out how to export in CSV



      Script:



      foreach($vds in Get-VDSwitch)
      {
      $vds.ExtensionData.Runtime.HostMemberRuntime | %{
      $.HealthCheckResult | where{$ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult]} |
      Select @{N='vdSwitch';E={$vds.Name}},
      UplinkPortKey,
      @{N='TrunkedVLAN';E={
      ($.TrunkedVLAN | %{
      if($
      .Start -eq $.End){
      "{0}" -f $
      .Start
      }
      else{
      "{0}-{1}" -f $.Start,$.End
      }
      }) -join ','

      }}
      }



      }



      The Output on screen look like this;



      VsanEnabled : False
      VsanDiskClaimMode : Manual
      HATotalSlots : 3099
      HAUsedSlots : 22
      HAAvailableSlots : 1527
      HASlotCpuMHz : 32
      HASlotMemoryMb : 328
      HASlotMemoryGB : 0.3203125
      HASlotNumVCpus : 1
      ParentId : Folder-group-h28
      ParentFolder : host
      HAEnabled : True
      HAAdmissionControlEnabled : True
      HAFailoverLevel : 1
      HARestartPriority : Medium
      HAIsolationResponse : DoNothing
      VMSwapfilePolicy : WithVM
      DrsEnabled : True
      DrsMode : FullyAutomated
      DrsAutomationLevel : FullyAutomated
      EVCMode : intel-nehalem
      Name : mac01dmzp01
      CustomFields : {}
      ExtensionData : VMware.Vim.ClusterComputeResource
      Id : ClusterComputeResource-domain-c12033
      Uid : /VIServer=cnt175726@mac01vcp02.cn.ca:443/Cluster=ClusterComputeResource-domain-c12033/



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 78
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 79
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 82
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 83
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 358
      TrunkedVLAN : 11-17,396,500



      vdSwitch : vds-toronto-mac01-2-ports-10Gbe
      UplinkPortKey : 359
      TrunkedVLAN : 11-17,396,500



      a lot more ......







      vmware






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 18:28







      Gerald Begin

















      asked Nov 20 '18 at 18:13









      Gerald BeginGerald Begin

      254




      254
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I found the way to do it, is with a function.



                      #####################################################
          # vSphere 6.5
          # Get ESX HealthCheck Network Config from VDS
          #
          # by Gerald Begin (Nov.20 2018)
          #################################

          ##### Set Script Location
          Set-Location T:___Main-Script____VDS-vLANs_

          ##### Add VMWare Module.
          Get-Module -Name VMware* -ListAvailable | Import-Module

          ##### Output Path
          $Desti = 'T:___Main-Script____VDS-vLANs_Output'

          Import-Module -Name "T:__Script_Functions__Connect2All.ps1" -Force:$true # Function to Connect to ALL vCenters

          $Clster = "mac01dmzp01"

          #### --------------------------------------

          function GetInfo {
          ###################################################

          foreach($vds in Get-VDSwitch)
          {
          $vds.ExtensionData.Runtime.HostMemberRuntime | %{
          $_.HealthCheckResult | where{$_ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult]} |
          Select @{N='vdSwitch';E={$vds.Name}},
          UplinkPortKey,
          @{N='TrunkedVLAN';E={
          ($_.TrunkedVLAN | %{
          if($_.Start -eq $_.End){
          "{0}" -f $_.Start
          }
          else{
          "{0}-{1}" -f $_.Start,$_.End
          }
          }) -join ','
          }}
          }
          }
          }


          Get-Cluster -Name $Clster | GetInfo | Export-Csv -Path $DestiResults.csv -NoTypeInformation

          Disconnect-VIServer * -Confirm:$false





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399073%2fvmware-output-the-network-healthcheck-in-on-csv-file%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I found the way to do it, is with a function.



                        #####################################################
            # vSphere 6.5
            # Get ESX HealthCheck Network Config from VDS
            #
            # by Gerald Begin (Nov.20 2018)
            #################################

            ##### Set Script Location
            Set-Location T:___Main-Script____VDS-vLANs_

            ##### Add VMWare Module.
            Get-Module -Name VMware* -ListAvailable | Import-Module

            ##### Output Path
            $Desti = 'T:___Main-Script____VDS-vLANs_Output'

            Import-Module -Name "T:__Script_Functions__Connect2All.ps1" -Force:$true # Function to Connect to ALL vCenters

            $Clster = "mac01dmzp01"

            #### --------------------------------------

            function GetInfo {
            ###################################################

            foreach($vds in Get-VDSwitch)
            {
            $vds.ExtensionData.Runtime.HostMemberRuntime | %{
            $_.HealthCheckResult | where{$_ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult]} |
            Select @{N='vdSwitch';E={$vds.Name}},
            UplinkPortKey,
            @{N='TrunkedVLAN';E={
            ($_.TrunkedVLAN | %{
            if($_.Start -eq $_.End){
            "{0}" -f $_.Start
            }
            else{
            "{0}-{1}" -f $_.Start,$_.End
            }
            }) -join ','
            }}
            }
            }
            }


            Get-Cluster -Name $Clster | GetInfo | Export-Csv -Path $DestiResults.csv -NoTypeInformation

            Disconnect-VIServer * -Confirm:$false





            share|improve this answer




























              0














              I found the way to do it, is with a function.



                          #####################################################
              # vSphere 6.5
              # Get ESX HealthCheck Network Config from VDS
              #
              # by Gerald Begin (Nov.20 2018)
              #################################

              ##### Set Script Location
              Set-Location T:___Main-Script____VDS-vLANs_

              ##### Add VMWare Module.
              Get-Module -Name VMware* -ListAvailable | Import-Module

              ##### Output Path
              $Desti = 'T:___Main-Script____VDS-vLANs_Output'

              Import-Module -Name "T:__Script_Functions__Connect2All.ps1" -Force:$true # Function to Connect to ALL vCenters

              $Clster = "mac01dmzp01"

              #### --------------------------------------

              function GetInfo {
              ###################################################

              foreach($vds in Get-VDSwitch)
              {
              $vds.ExtensionData.Runtime.HostMemberRuntime | %{
              $_.HealthCheckResult | where{$_ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult]} |
              Select @{N='vdSwitch';E={$vds.Name}},
              UplinkPortKey,
              @{N='TrunkedVLAN';E={
              ($_.TrunkedVLAN | %{
              if($_.Start -eq $_.End){
              "{0}" -f $_.Start
              }
              else{
              "{0}-{1}" -f $_.Start,$_.End
              }
              }) -join ','
              }}
              }
              }
              }


              Get-Cluster -Name $Clster | GetInfo | Export-Csv -Path $DestiResults.csv -NoTypeInformation

              Disconnect-VIServer * -Confirm:$false





              share|improve this answer


























                0












                0








                0







                I found the way to do it, is with a function.



                            #####################################################
                # vSphere 6.5
                # Get ESX HealthCheck Network Config from VDS
                #
                # by Gerald Begin (Nov.20 2018)
                #################################

                ##### Set Script Location
                Set-Location T:___Main-Script____VDS-vLANs_

                ##### Add VMWare Module.
                Get-Module -Name VMware* -ListAvailable | Import-Module

                ##### Output Path
                $Desti = 'T:___Main-Script____VDS-vLANs_Output'

                Import-Module -Name "T:__Script_Functions__Connect2All.ps1" -Force:$true # Function to Connect to ALL vCenters

                $Clster = "mac01dmzp01"

                #### --------------------------------------

                function GetInfo {
                ###################################################

                foreach($vds in Get-VDSwitch)
                {
                $vds.ExtensionData.Runtime.HostMemberRuntime | %{
                $_.HealthCheckResult | where{$_ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult]} |
                Select @{N='vdSwitch';E={$vds.Name}},
                UplinkPortKey,
                @{N='TrunkedVLAN';E={
                ($_.TrunkedVLAN | %{
                if($_.Start -eq $_.End){
                "{0}" -f $_.Start
                }
                else{
                "{0}-{1}" -f $_.Start,$_.End
                }
                }) -join ','
                }}
                }
                }
                }


                Get-Cluster -Name $Clster | GetInfo | Export-Csv -Path $DestiResults.csv -NoTypeInformation

                Disconnect-VIServer * -Confirm:$false





                share|improve this answer













                I found the way to do it, is with a function.



                            #####################################################
                # vSphere 6.5
                # Get ESX HealthCheck Network Config from VDS
                #
                # by Gerald Begin (Nov.20 2018)
                #################################

                ##### Set Script Location
                Set-Location T:___Main-Script____VDS-vLANs_

                ##### Add VMWare Module.
                Get-Module -Name VMware* -ListAvailable | Import-Module

                ##### Output Path
                $Desti = 'T:___Main-Script____VDS-vLANs_Output'

                Import-Module -Name "T:__Script_Functions__Connect2All.ps1" -Force:$true # Function to Connect to ALL vCenters

                $Clster = "mac01dmzp01"

                #### --------------------------------------

                function GetInfo {
                ###################################################

                foreach($vds in Get-VDSwitch)
                {
                $vds.ExtensionData.Runtime.HostMemberRuntime | %{
                $_.HealthCheckResult | where{$_ -is [VMware.Vim.VMwareDVSVlanHealthCheckResult]} |
                Select @{N='vdSwitch';E={$vds.Name}},
                UplinkPortKey,
                @{N='TrunkedVLAN';E={
                ($_.TrunkedVLAN | %{
                if($_.Start -eq $_.End){
                "{0}" -f $_.Start
                }
                else{
                "{0}-{1}" -f $_.Start,$_.End
                }
                }) -join ','
                }}
                }
                }
                }


                Get-Cluster -Name $Clster | GetInfo | Export-Csv -Path $DestiResults.csv -NoTypeInformation

                Disconnect-VIServer * -Confirm:$false






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 20 '18 at 18:45









                Gerald BeginGerald Begin

                254




                254






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399073%2fvmware-output-the-network-healthcheck-in-on-csv-file%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith