Hi All,
If you want to search large files in the folders or network locations, below is the PowerShell code.
workflow DirectoryCheck {
param([string[]]$FileShares,[int] $days ,[int] $sizeinMB)
$t=(get-date).adddays(-$days)
foreach –parallel -throttlelimit $fileshare.count ($Fileshare in $FileShares)
{
$DirArr = @()
$DirArr = Get-ChildItem -Path $Fileshare -Recurse -Directory | ? {$_.lastwritetime -ge $t }
foreach –parallel -throttlelimit 50 ($dir in $DirArr)
{
Get-ChildItem -Path $dir.FullName -File | ?{ $_.Length/1MB -ge $sizeinMB}| sort Length -desc | select Name,fullname, length, lastwritetime -First 100 -ExcludeProperty PSSourceJobInstanceId,PSComputerName
}
}
}
directorycheck -FileShares "C:\work\","D:\work" -days 800 -sizeinMB 1 |Out-GridView
get-childitem works really slowly if you have network locations to check. Below is the more information on that
https://blogs.msdn.microsoft.com/powershell/2009/11/04/why-is-get-childitem-so-slow/
I will post one more optimized script in upcoming posts.
Regards,
Chaitanya