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
}