Blog Post

PowerShell – Find top 10 Largest files of a local or remote Drive

,

Name of the function: Get-LargestFile

The Input parameters are ServerName and Drive.

Function call

PS:\>Get-LargestFile HQDB001 E

In this case HQDB001[ServerName] and E[Drive]

****************************

Code:-

***********************

Function Get-LargestFile([String]$server,[char]$drive)
{
Get-ChildItem \\$server\$drive$ -recurse -force -ErrorAction SilentlyContinue | Select-object Name,DirectoryName, @{Label=’Size’;Expression={($_.Length/1GB).ToString(‘F04′)}} | Sort Size -descending | select -First 10
}

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating