Skip to content

New TreeStoreDrive

Wolfgang Groß edited this page Apr 16, 2020 · 2 revisions

Persistent TreeStore Drives

TreeStore drives use LiteDb to store the data persistently. The database is opened None-exclusive to allow shared use between multiple powershell processes. Create a persistent drive based on a LiteDb database.

PS> New-TreeStoreDrive -Name tree -TreeStorePath "c:\tmp\data.db"

Creating a TreeStore drive creates a function in your PowerShell environment ":" to make it comfortable to switch to the drive:

PS> gc Function:\tree:
Set-Location $MyInvocation.MyCommand.Name

The scope of visibility of the drive and the generated navigation functions is configurable. If the TresStore drive is created by another module for example the drive and the navigation function is visible to the modules code only. This can be changed by specifying the global scope:

PS> New-TreeStoreDrive -Name tree -TreeStorePath "c:\tmp\data.db" -Scope Global

Non-Persistent (in memory) Drives

These drives are useful for testing purposes. Their content isn't shared between PowerShell processes. They also use LiteDb internally but are based on a MemoryStream instead of a FileStream.

New-TreeStoreDrive -Name tree

Using New-PSDrive

The New-TreeStoreDrive cmdlet calls internally the PowerShell provider frameworks 'NewDrive' method. It is possible to create a TreeStore drive without its custom cmdlet:

New-PSDrive -Name tree -Root ..\jumps.db -PSProvider TreeStore

If you use this method to create the drive a drive switching function ins't created.

Known Issues

Removing the drive with 'Remove-PSDrive' don't remove the drive switching function

Clone this wiki locally