-
1. Re: long datastore names truncated after Get-Datastore
alleninbroomfield Nov 9, 2018 2:01 PM (in response to COS)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 Nov 9, 2018 2:08 PM (in response to alleninbroomfield)My fault, I pasted in the incorrect commands.
See updated post.
-
3. Re: long datastore names truncated after Get-Datastore
LucD Nov 9, 2018 2:20 PM (in response to COS)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.
In fact this was one of the subjects we handled in out VMworld session VIN1992BU (US) and VIN1992BE (Europe).
-
4. Re: long datastore names truncated after Get-Datastore
LucD Nov 9, 2018 2:28 PM (in response to COS)To get the full name you can use the format operator (-f).
Like this
-
5. Re: long datastore names truncated after Get-Datastore
COS Nov 9, 2018 3:53 PM (in response to alleninbroomfield)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 Nov 9, 2018 2:39 PM (in response to alleninbroomfield)If you don't see that behaviour, then you are not looking correctly, unless you overwrote the default .ps1xml files that come with PowerCLI
-
7. Re: long datastore names truncated after Get-Datastore
COS Nov 9, 2018 2:41 PM (in response to LucD)@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 : 100Name : vmware-sql-logdir-test-t1-nfs02
FreeSpaceGB : 98.2705078125
CapacityGB : 100 -
8. Re: long datastore names truncated after Get-Datastore
LucD Nov 9, 2018 2:52 PM (in response to COS)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?
-
9. Re: long datastore names truncated after Get-Datastore
COS Nov 9, 2018 2:58 PM (in response to LucD)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 : 100Name : vmware-sql-logs-test-t1-nfs02
FreeSpaceGB : 99.10546875
CapacityGB : 100Any ideas?
-
10. Re: long datastore names truncated after Get-Datastore
alleninbroomfield Nov 9, 2018 3:06 PM (in response to COS)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 Nov 9, 2018 3:10 PM (in response to COS)What does $host.UI.RawUI.BufferSize say?
-
12. Re: long datastore names truncated after Get-Datastore
LucD Nov 9, 2018 3:13 PM (in response to COS)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?
-
13. Re: long datastore names truncated after Get-Datastore
alleninbroomfield Nov 9, 2018 3:21 PM (in response to LucD)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 Nov 9, 2018 3:27 PM (in response to LucD)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...