1 2 Previous Next 25 Replies Latest reply on Nov 9, 2018 4:23 PM by alleninbroomfield

    long datastore names truncated after Get-Datastore

    COS Master

      When I run the command below...

      Get-Cluster yomama | Get-Datastore | Sort-Object -Property FreeSpaceGB -Descending  | Format-Table -HideTableHeaders

       

      The output is truncated then appended with a "…"

      esx-somebody-made-long-name...

       

      The actual name is

      esx-somebody-made-long-name-for-the-hell-of-it

       

      Looks like if more than 29 or 30 characters it does this.

       

      What's the command to output the full name?

       

      Thanks

        • 1. Re: long datastore names truncated after Get-Datastore
          alleninbroomfield Novice

          I don't see that behavior.  What if you:

           

          $a = get-datacenter yomama  | get-cluster "jomama" | get-datastore

           

          then

           

          $a.Name

           

          Does it do it then?

          • 2. Re: long datastore names truncated after Get-Datastore
            COS Master

            My fault, I pasted in the incorrect commands.

             

            See updated post.

            • 3. Re: long datastore names truncated after Get-Datastore
              LucD Guru
              User ModeratorsvExpertCommunity Warriors

              The real explanation is that the PowerCLI cmdlets use Extended Data Types to display properties from PowerCLI objects.

              These data types are defined in the .ps1xml files that live in the PowerCLI modules.

              In this case the Name property of a Datastore object is limited to 30 characters.

              And 30 minus the three dots makes 27.

              This is the part of the VMware.VimAutomation.Format.ps1xml file where that is defined.

              ds-name.jpg

               

              In fact this was one of the subjects we handled in out VMworld session VIN1992BU (US) and VIN1992BE (Europe).

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: long datastore names truncated after Get-Datastore
                LucD Guru
                Community WarriorsvExpertUser Moderators

                To get the full name you can use the format operator (-f).

                Like this

                 

                Get-Datastore -Name esx* | Sort-Object -Property FreeSpaceGB -Descending  |

                 

                Select @{N='Name';E={"{0}" -f $_.Name}},FreeSpaceGB,CapacityGB

                 

                ds30.jpg

                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                • 5. Re: long datastore names truncated after Get-Datastore
                  COS Master

                  I modified my ps1 scripts and ran it in my .Net VB Windows Forms app and it worked like a charm!

                   

                  EDIT:

                  I was wrong, the FreeSpaceGB and CapacityGB did not come over.

                  Marked thread unanswered.

                  • 6. Re: long datastore names truncated after Get-Datastore
                    LucD Guru
                    User ModeratorsCommunity WarriorsvExpert

                    If you don't see that behaviour, then you are not looking correctly, unless you overwrote the default .ps1xml files that come with PowerCLI

                    Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                    • 7. Re: long datastore names truncated after Get-Datastore
                      COS Master

                      @LucD, I used your command like below with the cluster name....

                       

                      Get-Cluster jomama | Get-Datastore | Sort-Object -Property FreeSpaceGB -Descending | Select @{N='Name';E={"{0}" -f $_.Name}},FreeSpaceGB,CapacityGB

                       

                      But the output formatted like this....

                       

                       

                      Name        : vmware-sql-logs-test-t1-nfs02
                      FreeSpaceGB : 99.10546875
                      CapacityGB  : 100

                       

                       

                      Name        : vmware-sql-logdir-test-t1-nfs02
                      FreeSpaceGB : 98.2705078125
                      CapacityGB  : 100

                      • 8. Re: long datastore names truncated after Get-Datastore
                        LucD Guru
                        Community WarriorsvExpertUser Moderators

                        PowerShell normally uses a list, instead of a table, when there are 5 or more properties to show.
                        I have no clue why you get that behaviour with only 3 properties.

                         

                        Where are you running that code?

                        In VSC, ISE or from a PS prompt?

                        What does $host.UI.RawUI.BufferSize show?

                        Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                        • 9. Re: long datastore names truncated after Get-Datastore
                          COS Master

                          Here's the weird part.....

                           

                          When I run the command below in a plain single command in a PowerCLI window, the output format is correct.

                          Get-Cluster cos_wan2 | Get-Datastore | Sort-Object -Property FreeSpaceGB -Descending | Select @{N='Name';E={"{0}" -f $_.Name}},FreeSpaceGB,CapacityGB

                           

                          Name                                          FreeSpaceGB      CapacityGB

                          ----                                          -----------      ----------

                          vmware-sql-sysdb-test-t1-nfs02                  99.140625             100

                          vmware-sql-logs-test-t1-nfs02                 99.10546875             100

                           

                          But when I run the command from within a .ps1 file, that's when it gives me the output like below....

                           

                          Name        : vmware-sql-sysdb-test-t1-nfs02
                          FreeSpaceGB : 99.140625
                          CapacityGB  : 100

                           

                          Name        : vmware-sql-logs-test-t1-nfs02
                          FreeSpaceGB : 99.10546875
                          CapacityGB  : 100

                           

                          Any ideas?

                          • 10. Re: long datastore names truncated after Get-Datastore
                            alleninbroomfield Novice

                            I don't get that issue either.  Without seeing how you're executing it and where the output is going, it's difficult for me (personally, because I have a large imagination for all kinds of stuff you could be doing) to understand your issue.

                             

                            If I open a PowerCLI command prompt window and run your command, I get the formatted table.  If I cd to the directory of the same command in a .ps1 file and execute via ./filename.ps1 then it still works the same way for me.

                             

                            Care to give more info?

                            • 11. Re: long datastore names truncated after Get-Datastore
                              LucD Guru
                              User ModeratorsCommunity WarriorsvExpert

                              What does $host.UI.RawUI.BufferSize say?

                              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                              • 12. Re: long datastore names truncated after Get-Datastore
                                LucD Guru
                                Community WarriorsUser ModeratorsvExpert

                                You mention "PowerCLI window", which PowerCLI version are you using?

                                Recent PowerCLI version don't have a PowerCLI window anymore.

                                Are you using a shortcut from an older PowerCLI version?

                                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                                • 13. Re: long datastore names truncated after Get-Datastore
                                  alleninbroomfield Novice

                                  PowerCLI window is just a PS command window with import-module VMware.PowerCLI.  I still use it for VMware-specific stuff because I have a command window configured to auto-load the module and connect to a VI server, just saves time.

                                   

                                  I am curious--  I'm not sure what "Recent PowerCLI version don't have a PowerCLI window anymore" means... so what does it have?... just a standard PS command window and you manually load the module, or something else?  Educate me.

                                  • 14. Re: long datastore names truncated after Get-Datastore
                                    COS Master

                                    I use whatever the default install of 6.5 created on my desktops shortcut...

                                    Shortcut points to below....

                                    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\" $true"

                                     

                                    Here's the output of the windows...

                                     

                                    Output when executed from a .ps1 file...

                                    1 2 Previous Next