Skip to content

Instantly share code, notes, and snippets.

@jamiechalmerzlp
Created August 12, 2022 10:14
Show Gist options
  • Save jamiechalmerzlp/c61095df96d63793f982432d0eb4d6bb to your computer and use it in GitHub Desktop.
Save jamiechalmerzlp/c61095df96d63793f982432d0eb4d6bb to your computer and use it in GitHub Desktop.
$Files = Get-ChildItem -Path "your\directory\here" -File -Recurse -Name -Force -ErrorAction SilentlyContinue | Measure-Object | Select-Object @{Name='File(s) Count';Expression={$_.count}}
$Folders = Get-ChildItem -Path "your\directory\here" -Directory -Recurse -Name -Force -ErrorAction SilentlyContinue | Measure-Object | Select-Object @{Name='Folder Count';Expression={$_.count}}
write-host "Files: $Files"
write-host "Folders: $Folders"
@jamiechalmerzlp
Copy link
Author

I know this one leaves the @{} in the lines for output, and to be honest, I can't be bothered to clear it up... you are only using this as reference to count files and folders for verification purposes or something any way.

@pstakuu
Copy link

pstakuu commented Aug 12, 2022

Check this related one for reporting on the age of files in these directories - helps in sifting through and moving old data out - https://gist.github.com/pstakuu/e25fa725172342a5402a03de6633688f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment