How to find large files on a disk ?
The script will search the large files as per defined file size. The script has 2 input parameters
param([string] $SearchPath,[String] $FileSize) [string] $SearchPath [String] $FileSize #": Search file of size greater than (example : 1024GB or 1024MB)" $CurrentDate=Get-Date Write-Host `n "Search Start Time : " $CurrentDate -ForegroundColor Yellow if($SearchPath -eq " ") { foreach ($drive in (Get-PSDrive -PSProvider FileSystem)) { $DriveName=$drive.Name+":" if ((Test-Path -Path $DriveName) -eq "True") {Get-ChildItem $DriveName -Recurse -Force -ErrorAction Ignore | Where-Object {$_.Length -gt $FileSize}| ` SELECT Name,@{Name="FileSize[GB]";Expression={[math]::Round($_.Length / 1GB)}},LastWriteTIme ` -ErrorAction SilentlyContinue | Format-Table -AutoSize } } } else { if ((Test-Path -Path $SearchPath) -eq "True") {Get-ChildItem $SearchPath -Recurse -Force -ErrorAction Ignore | Where-Object {$_.Length -gt $FileSize}| ` SELECT Name,@{Name="FileSize[GB]";Expression={[math]::Round($_.Length / 1GB)}},LastWriteTIme ` -ErrorAction SilentlyContinue | Format-Table -AutoSize } } $CurrentDate=Get-Date Write-Host `n "Search End Time : " $CurrentDate -ForegroundColor Yellow