VMware Cloud Community
Nicolas4949
Contributor
Contributor
Jump to solution

Table format

Hello,

I discover powershell and PowerCLI.

I search list the Upgrade Policy Tools of all VM.

This script work's fine :

$report = @()
Foreach ( $v in Get-vm ) {
$vm = Get-View $v
$vms = "" | Select-Object VMName, ToolsUpgradePolicy
$vms.VMName = $vm.Name
$vms.ToolsUpgradePolicy = $vm.Config.Tools.ToolsUpgradePolicy
$report += $vms
}
$report | Sort ToolsUpgradePolicy

But, the ToolsUpgradePolicy column is not display, only VMName column.

If i add " | ft -auto" in the end, it's ok

Why?

Thx for your answer

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The PowrShell output formatter tries to place as much information as possible on the console.

For that it follows some rules. See How PowerShell Formatting and Outputting REALLY works

With the Format-Table -AutoSize instruction, you change the default behaviour.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

The PowrShell output formatter tries to place as much information as possible on the console.

For that it follows some rules. See How PowerShell Formatting and Outputting REALLY works

With the Format-Table -AutoSize instruction, you change the default behaviour.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos