]> apps.delaporte.us Git - dotfiles.git/blob - psmodules/file_management.psm1
Add doc for GitHub CLI token
[dotfiles.git] / psmodules / file_management.psm1
1 <#
2 .SYNOPSIS
3
4 Find 10 largest files on the C drive.
5
6 #>
7 function Show-LargeFiles() {
8 param(
9 [int]$Max=10
10 )
11 Get-ChildItem c:\ -r| sort -descending -property length | select -first $Max name, Length, FullName
12 }
13
14 <#
15 .SYNPOSIS
16
17 Display the free space on the C drive.
18
19 #>
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)
24 }
25 }
26
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
31 If($x -eq 100){
32 $x = 1
33 }
34 Else{
35 $x += 1
36 }
37 }
38 Write-Progress -Activity "Collecting Files..." -Completed
39 $Files = Get-Job -Name "FileCollection" | Receive-Job
40 Get-Job -Name "FileCollection" | Remove-Job
41 }
42
43 Export-ModuleMember -Function Show-DriveSpace
44 Export-ModuleMember -Function Show-LargeFiles
45
46 # Stay awake to allow large transfers to complete
47 # without permanently giving up battery saving features
48 function Invoke-StayAwake() {
49 param($minutes=90)
50 $wsh = New-Object -ComObject WScript.Shell
51 do{
52 "Staying awake for $minutes minutes"
53 $minutes-=1;
54 # Send Shift+F15
55 $wsh.SendKeys('+{F15}')
56 Start-Sleep -seconds 59
57 }until($minutes -lt 0)
58 # Thank you to http://www.zhornsoftware.co.uk/caffeine/
59 }
60
61 Export-ModuleMember -Function Invoke-StayAwake