Powershell - The $FormatEnumerationLimit variable
To support me, you can subscribe to the channel, share and like the videos, disable your ad blocker or make a donation. Thank you!
Hello,
A new article to introduce the $FormatEnumerationLimit variable and when Format-Table -Wrap doesn’t work.
Depending on the size of your console and font size, the content may not be truncated in my demonstration commands. You can in Windows Terminal or Powershell enlarge the font size punctually by pressing CTRL and turning the mouse wheel to get a conclusive result.
# Let's take the following example, where dependentservices is truncated for some servicesGet-Service | Format-Table -Property name, dependentservices
# To display the truncated content, we're tempted to do thisGet-service | Format-Table -Property name, dependentservices -wrap
# Syntax that works very well in this contextGet-Process ShellExperienceHost | Format-Table -Property name,pathGet-Process ShellExperienceHost | Format-Table -Property name,path -wrap
# Compare :Get-Process ShellExperienceHost | Format-Table -Property name,pathGet-Service nsi | Format-Table -Property name, dependentservices# The difference is in the {}, they indicate a collection of objects (Array).
# To display the full contents of dependentservices, I need to extend the propertyGet-Service nsi | Select-Object -ExpandProperty dependentservices# or(Get-Service nsi).dependentservices
# You can check the type of dependentservices:(Get-Service nsi | Select-Object -ExpandProperty dependentservices).gettype()
# But if I want to display the contents of dependentservices for all services, the result is unreadableGet-Service | Select-Object -ExpandProperty dependentservices
# In this case, you can modify a variable which indicates the number of elements to list (4 by default).# Display the value of the default variable$FormatEnumerationLimit# 4, the maximum number of results displayed in the collection
# Modify the value of $FormatEnumerationLimit$FormatEnumerationLimit = 8Get-Service nsi | Format-Table -Property name, dependentservices# It may be necessary to add a -wrap depending on the number of characters supported by the console and the number of characters to be displayed
Related links
Powershell - Simply send objects to different variables
Powershell - Tip - Simply send objects to different variablesPowershell - Testing network connectivity and port accessibility
Testing network connectivity and port accessibility with PowershellPowershell - Display network connections (equivalent to netstat)
Display network connections (listening ports, active connections...)Powershell - Testing name resolution (equivalent to nslookup)
Powershell commands to test name resolution (equivalent to nslookup)Powershell - View and manage DNS configuration of network interfaces
Powershell commands to display and manage DNS configuration of network interfacesPowershell - Managing IP configuration of network interfaces
Powershell commands to view and modify the IP configuration of network interfaces