Functions/Maintenance.ps1
function Maintenance { [CmdletBinding()] param ( [Parameter()] [switch] $UpdateAll, [Parameter()] [switch] $UpdatePSModules, [Parameter()] [switch] $UpdateHelp ) cua cr rdi Write-Host "`n----`n" Remove-DownloadFolderItems # Backup-MySettings -All # Set-ChocoPinList if (Get-Command Get-MpComputerStatus -ea 0) { $MpScan_Params = @{ AsJob = $true } if ((Get-MpComputerStatus).FullScanOverdue -eq $true) { $MpScan_Params.Add('ScanType', 'FullScan') } if ((Get-MpComputerStatus).QuickScanOverdue -eq $true -or (Get-MpComputerStatus).FullScanOverdue -eq $true) { Start-MpScan @MpScan_Params } } if ($UpdateAll -or $UpdatePSModules) { Start-Job -ScriptBlock { Get-InstalledModule | Update-Module -AcceptLicense -Verbose foreach ($m in Get-InstalledModule) { Get-InstalledModule $m.Name -AllVersions | Where-Object { $_.Version -ne $m.Version } | Uninstall-Module -Force } } } if ($UpdateAll -or $UpdateHelp) { Start-Job -ScriptBlock { Update-Help -Force -ea 0 } } } |