functions/Enable-CmdFavAutoBackup.ps1
function Enable-CmdFavAutoBackup { <# .SYNOPSIS Enables automatic backup for CmdFav and sets the backup path. .DESCRIPTION This function enables automatic backup for CmdFav by setting the backup path in the configuration (AutoBackup.Path) and enabling the AutoBackup.Enabled flag. The path must exist. .PARAMETER Path The directory path where backups should be stored. Must exist. .EXAMPLE Enable-CmdFavAutoBackup -Path "C:\Backups\CmdFav" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true, Position = 1)] [string]$Path ) if (-not (Test-Path -Path $Path -PathType Container)) { Stop-PSFFunction -Level Error -Message "Backup path does not exist: $absPath" return } $absPath = (Resolve-Path $Path).ProviderPath Set-PSFConfig -Module 'CmdFav' -Name 'AutoBackup.Path' -Value $absPath -Validation string -Description "Path for CmdFav automatic backups" -PassThru | Register-PSFConfig -Scope UserDefault Set-PSFConfig -Module 'CmdFav' -Name 'AutoBackup.Enabled' -Value $true -Validation bool -Description "Enable automatic backup for CmdFav" -PassThru | Register-PSFConfig -Scope UserDefault Write-PSFMessage -Level Host -Message "CmdFav automatic backup enabled. Path: $absPath" } |