4 Find 10 largest files on the C drive.
7 function Show-LargeFiles() {
10 [string]$path="C:\Users"
12 Get-ChildItem $path -r | sort -descending -property length | select -first $Max name, Length, FullName
18 Display the free space on the C drive.
21 function Show-Drivespace() {
22 Get-PSDrive C | Select-Object Used,Free | ForEach {
23 Write-Host "Free space GB: " ($_.Free / 1GB)
24 Write-Host "Used space GB: " ($_.Used / 1GB)
28 function Show-DrivespacePretty() {
29 Start-Job -Name "FileCollection" -ScriptBlock { Show-Drivespace }
30 While((Get-Job -Name "FileCollection").State -eq "Running") {
31 Write-Progress -Activity "Collecting Files..." -PercentComplete $x
39 Write-Progress -Activity "Collecting Files..." -Completed
40 $Files = Get-Job -Name "FileCollection" | Receive-Job
41 Get-Job -Name "FileCollection" | Remove-Job
44 Export-ModuleMember -Function Show-DriveSpace
45 Export-ModuleMember -Function Show-LargeFiles
47 # Stay awake to allow large transfers to complete
48 # without permanently giving up battery saving features
49 function Invoke-StayAwakeWindows() {
51 $wsh = New-Object -ComObject WScript.Shell
53 "Staying awake for $minutes minutes"
56 $wsh.SendKeys('+{F15}')
57 Start-Sleep -seconds 59
58 }until($minutes -lt 0)
59 # Thank you to http://www.zhornsoftware.co.uk/caffeine/
62 Export-ModuleMember -Function Invoke-StayAwakeWindows
64 function Invoke-StayAwake() {
67 "Staying awake for $minutes minutes"
68 systemd-inhibit sleep 60
70 }until($minutes -lt 0)
73 Export-ModuleMember -Function Invoke-StayAwake