How to stop Powershell truncating data?

apsutechteam
apsutechteam used Ask the Experts™
on
I am struggling to get my Powershell output to print out completed.  The data is just what I want ... but it truncates with ...}.
Get-Datastore | Select Name, @{N="NumVM";E={@($_ | Get-VM)}}

Such as :  DS-34            {apmyvdisa1, apmyvs1, apmyvdimr1, apmyfusionapp1...}

Can someone help with me with how to stop this:  I've Googled and tried variations of -autosize, -wrap, out-string, etc.. - I just can't make it stop.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jeremy WeisingerSenior Network Consultant / Engineer

Commented:
So FT -wrap doesn't work for you?
Get-Datastore | Select Name, @{N="NumVM";E={@($_ | Get-VM)}} | ft -wrap

Open in new window


Can you try Format-Custom? This is going to be a ton of info:
Get-Datastore | Select Name, @{N="NumVM";E={@($_ | Get-VM)}} | FC

Open in new window

Author

Commented:
Get-Datastore | Select Name, @{N="NumVM";E={@($_ | Get-VM)}} | ft -wrap

Gives me:
PowerCLI C:\> Get-Datastore | Select Name, @{N="NumVM";E={@($_ | Get-VM)}}

Name             NumVM
----             -----
DS-APBRNJ2-DATA2
DS-36            {apmyproj1, apbrarg2, apbrnetwrix2, apbrnetwrix...}
DS-ISOs          {apstudconnect, apbrvcenter, apbrnj2, apstigrhel7...}
*****************
*****************
The second suggestion gives me lots of errors - especially about deprecation --
WARNING: The 'CpuAffinity' property of VMResourceConfiguration type is deprecated. Use the 'CpuAffinityList' property
instead.
WARNING: The 'DrsMode' property of Cluster type is deprecated. Use the 'DrsAutomationLevel' property instead.
WARNING:  The 'ScsiLun' property of VMHostStorageInfo type is deprecated. Use 'Get-ScsiLun' cmdlet instead.
WARNING: The 'VMKernelGatewayDevice' property of VMHostNetworkInfo type is deprecated and will be removed in a future
release.
WARNING: The 'VirtualSwitch' property of VMHostNetworkInfo type is deprecated. Use 'Get-VirtualSwitch' cmdlet instead.
WARNING: The 'PhysicalNic' property of VMHostNetworkInfo type is deprecated. Use 'Get-VMHostNetworkAdapter' cmdlet
instead.
WARNING: The 'ConsoleNic' property of VMHostNetworkInfo type is deprecated. Use 'Get-VMHostNetworkAdapter' cmdlet
instead.
WARNING: The 'VirtualNic' property of VMHostNetworkInfo type is deprecated. Use 'Get-VMHostNetworkAdapter' cmdlet
instead.
WARNING: The value of 'ExtensionData' property of VMHostNetworkInfo type is deprecated and will be
Senior Network Consultant / Engineer
Commented:
Is this a typo?
PowerCLI C:\> Get-Datastore | Select Name, @{N="NumVM";E={@($_ | Get-VM)}}

If not, you're missing the | ft -wrap

Assuming it's a typo and you did specify the -wrap then it must be what you're calling in the select. You could try something like this:

Get-Datastore | Select Name, @{N="NumVM";E={($_ | Get-VM | select -ExpandProperty Name) -join ", "}} | ft -wrap

Open in new window

or
Get-Datastore | Select Name, @{N="NumVM";E={($_ | Get-VM | select -ExpandProperty Name)}} | ft -wrap

Open in new window

Unfortunately I'm only guessing. I'm not familiar with the VMWare cmdlets and I don't know what type of objects get returned.

So the FC is just expanding out everything in the objects. Those are warnings and not errors. They're just informational.
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Author

Commented:
This still didn't work:   PowerCLI C:\> Get-Datastore | Select Name, @{N="NumVM";E={($_ | Get-VM | select -ExpandProperty Name)}} | ft -wrap

Name             NumVM
----             -----
DS-APBRNJ2-DATA2
DS-36            {apmyproj1, apbrarg2, apbrnetwrix2, apbrnetwrix...}
DS-ISOs          {apstudconnect, apbrvcenter, apbrnj2, apstigrhel7...}
DS-25            {apmycf1, apbroc4}

However -- the one with the 'join' does work -- fabulous -- thank you .  Wow, why is this so difficult?

And yes,  the comment I'd sent back earlier was a 'bad copy' leaving off the end.
Jeremy WeisingerSenior Network Consultant / Engineer

Commented:
Glad to help. :)
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
Oh really?  Join works?  I wonder if that is simpler?

I found that unless you manually create the output your get wraps, I will mess with the carriage returns and lines on the script to get the desired output from FT but it's not perfect.

The only way I can really control the data is to manually put it in variables and print them myself, but then there is the issue of the spacing being terrible.

I keep thinking about creating my own version of FT that does the needful, but join seems like it may be a nice workaround.

I'll have ot play with it.
Jeremy WeisingerSenior Network Consultant / Engineer

Commented:
Solution provided.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial