Functions/Get-FileWithLeadingSpace.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
function Get-FileWithLeadingSpace { <# .SYNOPSIS To find files that begin with a space character .DESCRIPTION To find files that begin with a space character .PARAMETER Path The path where you want to begin looking .EXAMPLE Get-FileWithLeadingSpace -path Value Describe what this call does #> [CmdletBinding(ConfirmImpact='None')] Param([string] $Path=$PWD) begin { Write-Verbose -Message "Starting [$($MyInvocation.Mycommand)]" } process { Get-ChildItem -Path $Path -Recurse -ErrorAction SilentlyContinue | foreach-object { if ($_.name.length -ne $_.name.trim().length) { Write-Output -InputObject $_.FullName } } } end { Write-Verbose -Message "Ending [$($MyInvocation.Mycommand)]" } } |