I have two clusters, cluster1 with 5 nodes and cluster2 with 4 nodes. With below script the cluster1 output is getting truncated. How to address this problem?
PS C:\WINDOWS\system32> $temp = @()
PS C:\WINDOWS\system32> foreach($i in @('cluster1','cluster2')){
>> $pso = New-Object -TypeName psobject
>> $cluster = Get-Cluster $i | select name
>> $cluster_nodes = Get-ClusterNode -Cluster $cluster.Name | select name
>> $pso | Add-Member -MemberType NoteProperty -Name 'Cluster' -Value $cluster.Name
>> $pso | Add-Member -MemberType NoteProperty -Name 'Cluster_nodes' -Value $cluster_nodes.name
>> $temp += $pso
>> }
Output:
PS C:\WINDOWS\system32> $temp
Cluster Cluster_nodes
------- -------------
cluster1 {node1, node2, node3, node4...}
cluster2 {node1, node2, node3, node4}
AdminOfThings provided the crucial pointer in a comment on the question:
Preference variable
$FormatEnumerationLimitcontrols how many elements of a collection-valued property to display in formatted output.E.g,
$FormatEnumerationLimit = 2; [pscustomobject] @{ prop = 1, 2, 3 }prints (at most) 2 elements from.prop's value and hints at the existence of more with...; e.g.,{1, 2...}).The default value is
4, but you can set it to an arbitrary positive value.-1places no limit on how many values are displayed, but note that with tabular output (implicit or explicitFormat-Table) the column width may still truncate the value list.Format-Listto ensure that all values are shown.Caveat: Due to a bug as of PowerShell [Core] 7.0, setting
$FormatEnumerationLimitis only effective in the global scope - see this GitHub issue.$global:FormatEnumerationLimit, temporarily (restore it to the original value before exiting the script).