MicrosoftDocs / PowerShell-Docs

The official PowerShell documentation sources
https://learn.microsoft.com/powershell
Creative Commons Attribution 4.0 International
1.93k stars 1.55k forks source link

Get-SmallFiles example with PSDefaultValue attribute does not work #11128

Closed adrimus closed 2 months ago

adrimus commented 2 months ago

Type of issue

Code doesn't work

Feedback

Under Named Parameters, In the section where you can add PSDefaultValue to provide a brief help string, for example:

function Get-SmallFiles {
  param (
      [PSDefaultValue(Help = '100')]
      $Size = 100
  )
}

If I then execute the function it doesn't do anything, I think it should be:

function Get-SmallFiles  {
  param (
      [PSDefaultValue(Help = '100')]
      $Size = 100
  )
  Get-ChildItem $HOME | Where-Object {
    $_.Length -lt $Size -and !$_.PSIsContainer
  }
}

Page URL

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions?view=powershell-7.4

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/7.4/Microsoft.PowerShell.Core/About/about_Functions.md

Author

@sdwheeler

Document Id

004bf422-04f5-50e2-3c89-2ff449d2867f