Format-List by default displays object properties in a list, and if a property contains an array, the array is turned into text, and only a few array elements are displayed. Here is an example:

 
PS> Get-Process -Id $Pid | Format-List -Property Name, Modules


Name    : powershell_ise
Modules : {System.Diagnostics.ProcessModule (PowerShell_ISE.exe), 
          System.Diagnostics.ProcessModule (ntdll.dll), System.Diagnostics.ProcessModule 
          (MSCOREE.DLL), System.Diagnostics.ProcessModule (KERNEL32.dll)...}
 

This line gets the PowerShell process, and displays its name and the loaded modules. As you can see, the output does not show all loaded modules.

There is a magic variable called $FormatEnumerationLimit which controls how many array elements Format-List is showing.

By default, this limit is set to 4, so a maximum of 4 array elements are shown in the output. By setting the limit to -1, you effectively turn off the limit:

 
PS> $FormatEnumerationLimit
4

PS> $FormatEnumerationLimit = -1

PS> $FormatEnumerationLimit
-1 
 

When you now run the same command again, Format-List shows all array elements:

 
PS> Get-Process -Id $Pid | Format-List -Property Name, Modules


Name    : powershell_ise
Modules : {System.Diagnostics.ProcessModule (PowerShell_ISE.exe), 
          System.Diagnostics.ProcessModule (ntdll.dll), System.Diagnostics.ProcessModule 
          (MSCOREE.DLL), System.Diagnostics.ProcessModule (KERNEL32.dll), 
          System.Diagnostics.ProcessModule (KERNELBASE.dll), System.Diagnostics.ProcessModule 
          (ADVAPI32.dll), System.Diagnostics.ProcessModule (msvcrt.dll), 
          System.Diagnostics.ProcessModule (sechost.dll), System.Diagnostics.ProcessModule 
          (RPCRT4.dll), System.Diagnostics.ProcessModule (mscoreei.dll), 
          System.Diagnostics.ProcessModule (SHLWAPI.dll), System.Diagnostics.ProcessModule 
          (combase.dll), System.Diagnostics.ProcessModule (ucrtbase.dll), 
          System.Diagnostics.ProcessModule (bcryptPrimitives.dll), 
          System.Diagnostics.ProcessModule (GDI32.dll), System.Diagnostics.ProcessModule 
          (gdi32full.dll), System.Diagnostics.ProcessModule (msvcp_win.dll), 
          System.Diagnostics.ProcessModule (USER32.dll), System.Diagnostics.ProcessModule 
          (win32u.dll), System.Diagnostics.ProcessModule (IMM32.DLL), 
          System.Diagnostics.ProcessModule (kernel.appcore.dll), System.Diagnostics.ProcessModule 
          (VERSION.dll), System.Diagnostics.ProcessModule (clr.dll), 
          System.Diagnostics.ProcessModule (MSVCR120_CLR0400.dll), 
          System.Diagnostics.ProcessModule (mscorlib.ni.dll), System.Diagnostics.ProcessModule 
          (ole32.dll), System.Diagnostics.ProcessModule (uxtheme.dll), 
          System.Diagnostics.ProcessModule (tiptsf.dll), System.Diagnostics.ProcessModule 
          (OLEAUT32.dll), System.Diagnostics.ProcessModule (CRYPTSP.dll), 
          System.Diagnostics.ProcessModule (rsaenh.dll), System.Diagnostics.ProcessModule 
          (bcrypt.dll), System.Diagnostics.ProcessModule (CRYPTBASE.dll),  
(...)
 

Twitter This Tip! ReTweet this Tip!

Anonymous