5 Replies Latest reply on May 16, 2019 11:47 PM by LucD

    Split VM NAME in csv report use powercli

    kakekmuda Novice

      any body can help me ?

      split.PNG

      the real condition

      the real kondision.PNG

      like this

       

      vmname (xyz) , can i split this ?

      i use this code

       

      &{foreach($vm in (Get-VM)) {

       

       

          $vm.ExtensionData.Guest.Net | select -Property @{N='VM';E={$vm.Name}},

          @{N='OS';E={$vm.Guest.OSFullName}},

      @{N="NumCPU";E={$vm.NumCPU}},

      @{N="MemoryMB";E={$vm.MemoryMB}},

          @{N='IP';E={[string]::Join(',',($vm.Guest.IPAddress | Where {($_.Split(".")).length -eq 4}))}},

          @{N='Gateway';E={[string]::Join(',',($vm.ExtensionData.Guest.IpStack.IpRouteConfig.IpRoute | %{if($_.Gateway.IpAddress){$_.Gateway.IpAddress}}))}},

          @{N='Subnet Mask';E={

                      $dec = [Convert]::ToUInt32($(('1' * $_.IpConfig.IpAddress[0].PrefixLength).PadRight(32, '0')), 2)

                      $DottedIP = $( For ($i = 3; $i -gt -1; $i--) {

                              $Remainder = $dec % [Math]::Pow(256, $i)

                              (                        $dec - $Remainder) / [Math]::Pow(256, $i)

                              $dec = $Remainder

                          } )

                      [String]::Join('.', $DottedIP)

                  }},

          @{N="DNS";E={[string]::Join(',',($vm.ExtensionData.Guest.IpStack.DnsConfig.IpAddress))}},

          @{N='MAC';E={[string]::Join(',',$_.MacAddress)}}

        }

      } | Export-Csv -NoTypeInformation C:\Users\xyz\Desktop\xyz.csv

       

      Thank you all