A couple of questions about defaults (or lack thereof)

This topic contains 3 replies, has 3 voices, and was last updated by  tommymaynard 2 years, 12 months ago.

  • Author
  • #26783

    Arley Dealey

    I have a couple of questions about decisions which were made regarding defaults (or lack thereof).

    Anybody know why Format-Table doesn't default to -AutoSize? Everybody I know always uses this setting... unless they forget. Then they go "Doh!" and reissue the command with -AutoSize.

    The other decision that baffles me is why we need to add [cmdletbinding()] manually all the time. I can't recall a single script or function I've ever written where I didn't leverage this. Is there some reason for making it a manual addition?

  • #26784

    Don Jones

    AutoSize blocks the pipeline, which creates the perception of slower performance. Dunno if that's why, though.

    CmdletBinding was added in v2, I believe. It differentiates from older function types. Nowadays, I always use it also. But making it a default would break backward compat.

  • #26786

    Arley Dealey

    Both legit reasons. Thanks.

  • #26801


    Format-Table -AutoSize might be a good candidate for the $PSDefaultParameterValues preference variable. Here's a couple posts I wrote about it that will give your enough information to make -AutoSize the default: http://tommymaynard.com/?s=%24psdefaultparametervalues. Add this to your profiles, and it'll always be set.

You must be logged in to reply to this topic.