Thanks for everyone that has helped so far, I have this script that I am working on, I have this one section that does not display correctly, it's in bold, the rest is working correctly. Basically, when it retrieves the names of the data centers, they come in as a table, showing that it's a hash table..similar to this:
vSphere Data Center(s) { @{Name=DC1}, @{Name=DC2} } and so on
I tried changing some things around, I would use Select-Object Name, and try some subexpressions, but they just don't work. The output of the other data looks like this:
ESXihostCount : 4
vSphere Version: 5.0.0 : 9
vSphere Version: 4.1.0 : 7 I changed the numbers around...I know, no reason to, but I'm paranoid and I like to stay in that habit.
HW Model: ProLiant BL490c G6 : 1
HW Model: ProLiant BL460c G7 : 2
HW Model: ProLiant BL460c G1 : 1
HW Model: ProLiant BL460c G6 : 1
HW Model: ProLiant DL160 G6 : 1
I just want the curley braces removed, and I'm not sure how.
Portion of the Script
Thanks in advance
That's because you have more than 1 value in that field.
One trick you can use is to convert that array to a string.
Suppose the variable $dc contains the array with names, then you can do
[string]::Join(',',$dc)
This will generate a string like "DC1,DC2,DC3"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Instead of
Select-Object -Property Name
try
Select-Object -ExpandProperty Name
That way you get a value and not the object that is normally returned by Select-Object.
You can of course also do
(Select-Object -Property Name).Name
but that is not really "elegant" and clean PowerShell
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for your help...again
I really want to slap myself, I browse the community forums and I saw you suggest the same solution for a different member. I event went to powershell help and read about. In fact, I think you helped me with something similar to this on another script...of course, when it came time for me to use this, I completely forgot about it.
I do have 1 small issue, for the most part when I use any of your suggestions, they work. They still show up as a tablue however, it looks better than before, but the output is now:
vSphere Data Center(s) : {DC1, DC2, DC3}
I tried to pipe my info to fl, but that does not change anything. Any suggestions? It still looks much better though.
That's because you have more than 1 value in that field.
One trick you can use is to convert that array to a string.
Suppose the variable $dc contains the array with names, then you can do
[string]::Join(',',$dc)
This will generate a string like "DC1,DC2,DC3"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I know you have heard this many times, but you are the man. That worked perfectly. I really want to be like you when I grow up...thank you so much.