I want to get total file count and count of files newer than a specific date without having to do 2 separate calls. Is there a way do get both of these counts in 1 call?
Inefficient Way:
cls
$compareDate = (Get-Date).AddDays(-365)
$FileShare = "C:\Folder\Subfolder"
$TotalCount = (Get-ChildItem -File -Recurse $FileShare | Measure-Object).Count
$ActiveCount = (Get-ChildItem -File -Recurse $FileShare | Where-Object { $_.LastWriteTime -gt $compareDate}).Count
$Percentage = ($ActiveCount/$TotalCount)*100
Write-Host $ActiveCount/$TotalCount " is " $Percentage.ToString("#.##") "% Active"