Question
How to write a function to display all files samller than a size parameter (directories should be excluded)?

The following example is a function called Get-SmallFiles. This function has a $size parameter. The function displays all the files that are smaller than the value of the $size parameter, and it excludes directories:

function Get-SmallFiles { Param($Size) Get-ChildItem$HOME | Where-Object { $_.Length -lt$Size -and !$_.PSIsContainer } } Question How to write a function to display all files samller than a size parameter (directories should be excluded)? Answer ? Question How to write a function to display all files samller than a size parameter (directories should be excluded)? Answer The following example is a function called Get-SmallFiles. This function has a $size parameter. The function displays all the files that are smaller than the value of the $size parameter, and it excludes directories: function Get-SmallFiles { Param($Size) Get-ChildItem $HOME | Where-Object {$_.Length -lt $Size -and !$_.PSIsContainer }
}
If you want to change selection, open document below and click on "Move attachment"

two methods. When you run the function, the value you supply for a parameter is assigned to a variable that contains the parameter name. The value of that variable can be used in the function. <span>The following example is a function called Get-SmallFiles. This function has a $size parameter. The function displays all the files that are smaller than the value of the$size parameter, and it excludes directories: function Get-SmallFiles { Param($Size) Get-ChildItem$HOME | Where-Object { $_.Length -lt$Size -and !$_.PSIsContainer } } In the function, you can use the$size variable, which is the name defined for the parameter. To use this function, type the following command: Get-SmallFiles -Size 50 You can also ente

#### Summary

status measured difficulty not learned 37% [default] 0

No repetitions