Private/Save-DuneSession.ps1
|
<#
.SYNOPSIS Persist the current Dune session to disk. .DESCRIPTION Exports the script-scoped DuneSession to `~/.dune/session.clixml` using `Export-CliXml`. Creates the file if it does not exist. Warns if no session is available. .EXAMPLE PS> Save-DuneSession Saves the current session to disk for reuse in future PowerShell sessions. #> function Save-DuneSession { $path = "$HOME\.dune\session.clixml" if ($DuneSession) { if (-not (Test-Path $path)) { $null = New-Item -ItemType File -Path $path -Force } $null = $DuneSession | Export-CliXml -Path $path Write-Verbose "Session information saved" } else { Write-Warning "Can not save session. No session found" } } |