4 Find 10 largest files on the C drive.
7 function Show-LargeFiles() {
11 Get-ChildItem c:\ -r| sort -descending -property length | select -first $Max name, Length, FullName
17 Display the free space on the C drive.
20 function Show-Drivespace() {
21 Get-PSDrive C | Select-Object Used,Free | ForEach {
22 Write-Host "Free space GB: " ($_.Free / 1GB)
23 Write-Host "Used space GB: " ($_.Used / 1GB)
27 function Show-DrivespacePretty() {
28 Start-Job -Name "FileCollection" -ScriptBlock { Show-Drivespace }
29 While((Get-Job -Name "FileCollection").State -eq "Running") {
30 Write-Progress -Activity "Collecting Files..." -PercentComplete $x
38 Write-Progress -Activity "Collecting Files..." -Completed
39 $Files = Get-Job -Name "FileCollection" | Receive-Job
40 Get-Job -Name "FileCollection" | Remove-Job
43 Export-ModuleMember -Function Show-DriveSpace
44 Export-ModuleMember -Function Show-LargeFiles
46 # Stay awake to allow large transfers to complete
47 # without permanently giving up battery saving features
48 function Invoke-StayAwake() {
50 $wsh = New-Object -ComObject WScript.Shell
52 "Staying awake for $minutes minutes"
55 $wsh.SendKeys('+{F15}')
56 Start-Sleep -seconds 59
57 }until($minutes -lt 0)
58 # Thank you to http://www.zhornsoftware.co.uk/caffeine/
61 Export-ModuleMember -Function Invoke-StayAwake