Update list-hidden-files.ps1

This commit is contained in:
Markus Fleschutz 2023-10-24 09:45:23 +02:00
parent 7ba6813c67
commit 3a5aa8a8cc

View File

@ -1,30 +1,35 @@
<# <#
.SYNOPSIS .SYNOPSIS
Lists hidden files in a directory tree Lists all hidden files in a directory tree
.DESCRIPTION .DESCRIPTION
This PowerShell script scans and lists all hidden files in a directory tree. This PowerShell script scans a directory tree and lists all hidden files.
.PARAMETER DirTree .PARAMETER path
Specifies the path to the directory tree Specifies the path to the directory tree (default is current working dir)
.EXAMPLE .EXAMPLE
PS> ./list-hidden-files.ps1 C:\ PS> ./list-hidden-files.ps1 C:\Windows
...
Found 256 hidden files within 📂C:\Windows in 40 sec
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
param([string]$DirTree = "$PWD") param([string]$path = "$PWD")
try { try {
$DirTree = resolve-path "$DirTree" $stopWatch = [system.diagnostics.stopwatch]::startNew()
write-progress "Listing hidden files in $DirTree ..."
[int]$Count = 0 $path = Resolve-Path "$path"
get-childItem "$DirTree" -attributes Hidden -recurse | foreach-object { Write-Progress "Scanning $path for hidden files..."
[int]$count = 0
Get-ChildItem "$path" -attributes Hidden -recurse | Foreach-Object {
"📄 $($_.FullName)" "📄 $($_.FullName)"
$Count++ $count++
} }
"✔️ directory tree $DirTree has $Count hidden file(s)" Write-Progress -completed " "
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✔️ Found $count hidden files within 📂$path in $elapsed sec"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"