4 Find 10 largest files on the C drive.
7 function Show-LargeFiles() {
8 Get-ChildItem c:\ -r| sort -descending -property length | select -first 10 name, Length, FullName
14 Display the free space on the C drive.
17 function Show-Drivespace() {
18 Get-PSDrive C | Select-Object Used,Free | ForEach {
19 Write-Host "Free space GB: " ($_.Free / 1GB)
20 Write-Host "Used space GB: " ($_.Used / 1GB)
24 function Show-DrivespacePretty() {
25 Start-Job -Name "FileCollection" -ScriptBlock { Show-Drivespace }
26 While((Get-Job -Name "FileCollection").State -eq "Running") {
27 Write-Progress -Activity "Collecting Files..." -PercentComplete $x
35 Write-Progress -Activity "Collecting Files..." -Completed
36 $Files = Get-Job -Name "FileCollection" | Receive-Job
37 Get-Job -Name "FileCollection" | Remove-Job
40 Export-ModuleMember -Function Show-Drivespace
41 Export-ModuleMember -Function Show-DrivespacePretty
42 Export-ModuleMember -Function Show-LargeFiles