<# FPS:Containers:DataResources:SC-KPXtract:ACTIVE
#>
if (!(Push-NeededFor KPXtract)) {
# Remove a prior patch if it already exists
Remove-Item -Path Function:\KPXtract
} else {
# Only load the help line if a prior release is not
present, otherwise just keep whats
there.
$kpShortcuts = @($kpShortcuts
(ConvertTo-DotFill $global:SCDotLen 'KPXtract')+"[ ] Extracts the entire KeePass directory to XML in
Collections."
)
}
function KPXtract {
<#
.DESCRIPTION
Module: DataRecources
Shortcut: SC-KPXtract.ps1
Has Dependencies: Yes
This CmdLet encapsulates the
process of extracting the entire KeePass database to XML.
.EXAMPLE
if (Push-NeededFor KPXtract) { . (Get-ActiveFileNm -PS1 KPXtract) }
.CC
[2024.11.07 JD] Updates made to the shortcuts for ConvertTo-DotFill use
[2024.10.18 JD] Original code release
.NOTES
As written, all local sites within the runtime director
are sync'd with the source. The LoadPublicHTML
switched
conditional can be further modified for individual sites
during the local site sync - if necessary.
#>
[CmdletBinding()]
param(
)
#region KP Init
$overrideSrc, $overrideSnippet = '','' #
Initialize override variables
#$overrideSrc, $overrideSnippet
= 'SC-KPXtract','SC-KPXtract'
. (Get-ActiveFileNm -PS1 Initialize-DataResources-Locations)
. (Get-ActiveFileNm -PS1 OpenKP)
#$overrideSrc, $overrideSnippet
= '',''
if (Test-Path $drcLoc_KPXML) {
Remove-Item $drcLoc_KPXML }
#endregion KP Init
#region KPXtract Shortcut
$pei = New-Object KeePass.DataExchange.PwExportInfo @($kpDB.RootGroup, $kpDB)
$iocOut = [KeePassLib.Serialization.IOConnectionInfo]::FromPath($drcLoc_KPXML)
$ffp = [KeePass.Program]::FileFormatPool.Find('KeePass XML (2.x)')
if ($ffp.SupportsExport -and $ffp.TryBeginExport())
{
$s = [KeePassLib.Serialization.IOConnection]::OpenWrite($iocOut)
$ffp.Export($pei, $s, $null) | Out-Null
$s.Dispose()
}
#endregion KPXtract Shortcut
#region KP Close
. (Get-ActiveFileNm -PS1 CloseKP)
#endregion KP Close
}