]> apps.delaporte.us Git - dotfiles.git/blob - psmodules/drivespace.psm1
Stay awake for a bit.
[dotfiles.git] / psmodules / drivespace.psm1
1 <#
2 .SYNOPSIS
3
4 Find 10 largest files on the C drive.
5
6 #>
7 function Show-LargeFiles() {
8 Get-ChildItem c:\ -r| sort -descending -property length | select -first 10 name, Length, FullName
9 }
10
11 <#
12 .SYNPOSIS
13
14 Display the free space on the C drive.
15
16 #>
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)
21 }
22 }
23
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
28 If($x -eq 100){
29 $x = 1
30 }
31 Else{
32 $x += 1
33 }
34 }
35 Write-Progress -Activity "Collecting Files..." -Completed
36 $Files = Get-Job -Name "FileCollection" | Receive-Job
37 Get-Job -Name "FileCollection" | Remove-Job
38 }
39
40 Export-ModuleMember -Function Show-Drivespace
41 Export-ModuleMember -Function Show-LargeFiles