Closed as-slonneman closed 5 months ago
PowerCommander v0.9.8 adds Copy-KeeperFileAttachment
cmdlet.
Downloads filename.txt
file attachment from all records into 'OutFolder' folder
Copy-KeeperFileAttachment -Folder \ -Recursive -Name 'filename.txt' 'OutFolder'
Downloads all file attachments for a record
Copy-KeeperFileAttachment -Record <RECORD_UID>
Is it possible to also add the ability to return the file as a MemoryStream so that users of the function don't have to write a file to the system? This would allow users to directly use the file in memory so they don't have to write the file to the system then read it back in a again?
Copy-KeeperFileAttachmentToStream
cmdlet is added.
$stream = New-Object System.IO.MemoryStream
Copy-KeeperFileAttachmentToStream -Record <RECORD_UID> -AttachmentName <OPTIONAL_ATTACHMENT_NAME> $stream
$stream.Seek(0, 0)
The PowerShell Module is currently unable to download FIleRecords. This would be useful in scenarios where a user may use certificate based authentication and they store the certificate as an attachment to a Login Record. Implementation of this is as simple as a FileCommands.ps1 file with the code that would return a MemoryStream:
`function Get-FileRecord { param( [string] $recordUid )
[KeeperSecurity.Vault.VaultOnline]$vault = getVault if ($recordUid) { [KeeperSecurity.Vault.FileRecord] $record = $null if ($vault.TryGetKeeperRecord($recordUid, [ref]$record)) { $fileStream = [System.IO.MemoryStream]::new() $vault.DownloadFile($record, $fileStream).GetAwaiter().GetResults() | Out-Null return $fileStream }} }`