{"id":2147,"date":"2010-05-03T13:12:46","date_gmt":"2010-05-03T21:12:46","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=2147"},"modified":"2010-05-03T13:13:19","modified_gmt":"2010-05-03T21:13:19","slug":"your-output-may-vary","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2010\/05\/03\/your-output-may-vary\/","title":{"rendered":"Your output may vary"},"content":{"rendered":"<p>While I was testing the new PowerShell enabled RSEE service, I used one of the many files our users send us to illustrate one thing or another or to report a bug. Using real world script files rather than some &#8220;clean&#8221; in-house samples makes for a better test as far as I am concerned.<\/p>\n<p>(Disclaimer: Any such script containing personal information or access information of any kind is either made to be anonymous or deleted.)<\/p>\n<p>While testing, I noticed that get-process produced a list style output rather than the familiar table that get-process normally emits. An hour or two of investigating this brought the script down to two lines:<\/p>\n<p>get-date<br \/>get-process<\/p>\n<p>Running those two lines from the shell worked fine, but using them inside a script &#8220;getprocesses.ps1&#8221; and running them with<br \/>.\/getprocess.ps1<br \/>produces the different output.<\/p>\n<p>The original script was far more complex, issuing a dated report about checking server processes running and restarting them if so required, but trimming it down to these two lines is sufficient to see the the effect.<\/p>\n<p>As it turns out, if you simply use get-date or any other of an assorted list of cmdlets, the output of get-process reverts back to a list rather than a table. Other cmdlets emitting tables by default are affected as well and using<\/p>\n<p>get-process | format-table<\/p>\n<p>just results in an error message.<\/p>\n<p>When I asked the original author of the script if he noticed that difference in output he responded as follows:<\/p>\n<p>&#8220;Yes, I noticed. As a matter of fact, I banged my head against this for quite some time but I found no way to make get-process print a table again. I finally gave up and learned to live with the list output.&#8221;<\/p>\n<p>I am hoping that knowing this will prevent some &#8220;head banging&#8221; for you guys out there. Keep in mind that the output of your cmdlets in a script may be different from what you see when using them in the shell. It seems it depends on how you mix them together.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While I was testing the new PowerShell enabled RSEE service, I used one of the many files our users send us to illustrate one thing or another or to report a bug. Using real world script files rather than some &#8220;clean&#8221; in-house samples makes for a better test as far as I am concerned. (Disclaimer: [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[567,260,568,28,447],"class_list":["post-2147","post","type-post","status-publish","format-standard","hentry","category-windows-powershell","tag-format-table","tag-get-date","tag-get-process","tag-powershell","tag-script"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/2147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=2147"}],"version-history":[{"count":2,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/2147\/revisions"}],"predecessor-version":[{"id":2152,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/2147\/revisions\/2152"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=2147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=2147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=2147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}