Prepare ms-private 0.0.1 release candidate

This commit is contained in:
0x000 committed 2026-09-22 21:21:41 -04:00
1 parent 7aacc0b63f
commit a515538438
75 files changed
+3957 -3484

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
#Requires -Version 5.1
[CmdletBinding(SupportsShouldProcess)]param([ValidateSet('Plan','Run','InstallSchedule','RemoveSchedule')][string]$Mode='Plan',[ValidateRange(0,365)][int]$AgeDays=7,[string[]]$Category=@('Temp'),[ValidateSet('Daily','Weekly')][string]$Frequency='Daily',[switch]$ClearClipboard,[switch]$Json)
Set-StrictMode -Version Latest;$ErrorActionPreference='Stop';Import-Module (Join-Path $PSScriptRoot 'src/Wind.Core.psm1');Import-Module (Join-Path $PSScriptRoot 'src/Wind.Cleanup.psm1')
$Category=@($Category|ForEach-Object{$_.Split(',')}|ForEach-Object{$_.Trim()}|Where-Object{$_}|Select-Object -Unique);$valid=@('Temp','CrashReports','RecentItems','ThumbnailCache','PowerShellHistory','BrowserCache','WindReports');if(@($Category|Where-Object{$_-notin$valid}).Count){throw 'Unknown cleanup category.'}
$plan=if($Mode-in@('Plan','Run')){Get-WindCleanupPlan -AgeDays $AgeDays -Category $Category}else{$null}
if($Mode-eq'Plan'){if($Json){$plan|ConvertTo-Json -Depth 7}else{$plan|Select-Object FileCount,Bytes,AgeDays,Exclusions|Format-List;$plan.Files|Select-Object Path,Length,LastWriteUtc|Format-Table -Wrap};return}
$root=Join-Path ([Environment]::GetFolderPath('LocalApplicationData')) 'MsPrivate\cleanup';[IO.Directory]::CreateDirectory($root)|Out-Null
if($Mode-eq'Run'){$report=Join-Path $root ((Get-Date -Format 'yyyyMMdd-HHmmss')+'-'+[guid]::NewGuid().ToString('N')+'.json');Invoke-WindCleanup -Plan $plan -ReportPath $report -Confirm:$false|Format-List;if($ClearClipboard){Clear-WindCurrentClipboard;Write-Output 'Current clipboard cleared.'};Write-Output "Cleanup report: $report";return}
Assert-WindMutationAllowed
if($Mode-eq'InstallSchedule'){if($AgeDays-lt 1){throw 'Scheduled cleanup requires AgeDays of at least 1.'};if($PSCmdlet.ShouldProcess('Task Scheduler','Install safe cleanup schedule')){Install-WindCleanupSchedule -AgeDays $AgeDays -Frequency $Frequency -SourceRoot $PSScriptRoot};return}
if($PSCmdlet.ShouldProcess('Task Scheduler','Remove safe cleanup schedule')){Remove-WindCleanupSchedule}