Avatar of C Emmons
C Emmons
Flag for United States of America asked on

How to stop Powershell truncating data?

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
Powershell

Avatar of undefined
Last Comment
Jeremy Weisinger

8/22/2022 - Mon
Jeremy Weisinger

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

C Emmons

ASKER
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
ASKER CERTIFIED SOLUTION
Jeremy Weisinger

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
C Emmons

ASKER
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.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Jeremy Weisinger

Glad to help. :)
Ben Personick (Previously QCubed)

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 Weisinger

Solution provided.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.