{"id":12031,"date":"2011-11-20T00:01:00","date_gmt":"2011-11-20T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2011\/11\/20\/change-a-powershell-preference-variable-to-reveal-hidden-data\/"},"modified":"2011-11-20T00:01:00","modified_gmt":"2011-11-20T00:01:00","slug":"change-a-powershell-preference-variable-to-reveal-hidden-data","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/change-a-powershell-preference-variable-to-reveal-hidden-data\/","title":{"rendered":"Change a PowerShell Preference Variable to Reveal Hidden Data"},"content":{"rendered":"<p><b>Summary<\/b>: Change the <b>$FormatEnumerationLimit<\/b> Windows PowerShell preference variable and display more data in the console.<\/p>\n<p>&nbsp;<\/p>\n<p>Microsoft Scripting Guy Ed Wilson here. It is approaching the holiday season in Charlotte, North Carolina, in the United States. From now until the middle of January, 2012, many companies are on &ldquo;IT lockdown&rdquo; and are not making any changes. In fact, for many companies, they have been on IT lockdown for more than a month. There are several reasons for this lockdown: One reason is because of the number of people taking their vacation during the months of November and December. Another reason is because of the number of year-end reports that need to run during this time of the year. As a result of the critical reports that run, many companies do not want to risk anything adverse happening to their IT infrastructure, so they freeze any changes until after the new year.<\/p>\n<p>One big advantage of having an IT lockdown towards the end of the year is it provides time for IT pros to take advantage of either formal or informal training opportunities. Labs are built, scenarios are tested, and much learning takes place.<\/p>\n<p>At the Scripting Household, we are also in IT lockdown mode, and the Scripting Wife is ensuring no unplanned outages occur because of infrastructure changes. This also means I have time to experiment and to learn new things.<\/p>\n<p>I recently found something in the Windows PowerShell help files I had either not previously noticed or had forgotten. I was reading the <b>about_Preference<\/b> help topic. What I found is the <b>$FormatEnumerationLimit<\/b> preference variable. By default the <b>$FormatEnumerationLimit<\/b> preference variable has a value of 4, and it determines how many items are displayed when a property contains more than a single item.<\/p>\n<p>To obtain the current <b>$FormatEnumerationLimit<\/b>, I directly query the variable. In the following figure, I query the <b>$FormatEnumerationLimit<\/b>. Next, I use the <b>Get-Service<\/b> cmdlet to return information about all services that begin with the letters <i>win. <\/i>I first pipe the results to the <b>Format-Table<\/b> cmdlet and choose the name and the <b>dependentServices<\/b> property. I use the <i>autosize <\/i>parameter to tighten up the display. Next, I repeat the command and pipe the results to the <b>Format-List<\/b> cmdlet. In both cases, there is plenty of room in the Windows PowerShell console window to display additional <b>DependentServices<\/b>, but the space is not utilized because the number of items enumerated is limited to four, which is the default setting of the <b>$FormatENumerationLimit<\/b> preference variable. The three commands are shown here:<\/p>\n<p style=\"padding-left: 30px\">$FormatEnumerationLimit<\/p>\n<p style=\"padding-left: 30px\">get-service -Name win* | format-table name, dependent* -AutoSize<\/p>\n<p style=\"padding-left: 30px\">get-service -Name win* | format-list name, dependent*<\/p>\n<p>The commands and associated output are shown in the following figure.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6888.hsg-11-20-11-1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6888.hsg-11-20-11-1.png\" alt=\"Image of commands and associated output\" title=\"Image of commands and associated output\" \/><\/a><\/p>\n<p>I change the value of the <b>$FormatEnumerationLimit<\/b> variable to 20. Next, I retry my two <b>Get-Service<\/b> commands. The three commands are shown here:<\/p>\n<p style=\"padding-left: 30px\">$FormatEnumerationLimit = 20<\/p>\n<p style=\"padding-left: 30px\">get-service -Name win* | format-table name, dependent* -AutoSize<\/p>\n<p style=\"padding-left: 30px\">get-service -Name win* | format-list name, dependent*<\/p>\n<p>The commands and associated output are shown in the following figure.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0020.hsg-11-20-11-2.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0020.hsg-11-20-11-2.png\" alt=\"Image of commands and associated output\" title=\"Image of commands and associated output\" \/><\/a><\/p>\n<p>When <b>$FormatEnumerationLimit<\/b> is set to the default value of 4, a command to retrieve all processes that begin with the letter <i>w<\/i>;<i> <\/i>sort based upon <i>pagedmemorysize<\/i>; and display a table containing the name and all properties that begin with the letters <i>page<\/i>;<i> <\/i>and the threads fit neatly in a table. The problem is that the threading information truncates after four thread values. The command is shown here:<\/p>\n<p style=\"padding-left: 30px\">Get-Process w* | sort pagedmemorysize | ft name, page*, threads -Wrap &ndash;AutoSize<\/p>\n<p>The command and associated output are shown in the following figure.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5025.hsg-11-20-11-3.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5025.hsg-11-20-11-3.png\" alt=\"Image of command and associated output\" title=\"Image of command and associated output\" \/><\/a><\/p>\n<p>When the same command runs with the <b>$FormatEnumerationLimit<\/b> set to 20, the output spreads out more. The advantage is that all the thread IDs appear in the output.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1643.hsg-11-20-11-4.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1643.hsg-11-20-11-4.png\" alt=\"Image of thread IDs in the output\" title=\"Image of thread IDs in the output\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Well, this is the easy way to see behind the ellipsis in some of the output. I do not think I will add the command to my profile, but it is definitely something to keep in mind when I want to see more output, but I do not want to use the <b>Select-Object &ndash;expandproperty<\/b> command. I will see you tomorrow when I begin a new week on the Hey, Scripting Guy Blog!<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Change the $FormatEnumerationLimit Windows PowerShell preference variable and display more data in the console. &nbsp; Microsoft Scripting Guy Ed Wilson here. It is approaching the holiday season in Charlotte, North Carolina, in the United States. From now until the middle of January, 2012, many companies are on &ldquo;IT lockdown&rdquo; and are not making any [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[51,3,4,61,45],"class_list":["post-12031","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-scripting-guy","tag-scripting-techniques","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Change the $FormatEnumerationLimit Windows PowerShell preference variable and display more data in the console. &nbsp; Microsoft Scripting Guy Ed Wilson here. It is approaching the holiday season in Charlotte, North Carolina, in the United States. From now until the middle of January, 2012, many companies are on &ldquo;IT lockdown&rdquo; and are not making any [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/12031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=12031"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/12031\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=12031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=12031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=12031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}