Manage snapshots PowerShell script

  • Updated

Basic example of management of your Filespace snapshots. List, create, activate, delete your snapshots easily through a PowerShell script when linked to a Filespace as 'root' user. 

Activate a snapshot and deactivate your snapshot back to your live Filespace. 


C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "managesnapshots.ps1"


using namespace System.Management.Automation.Host

function Menu {

    while ($true) {
    $list = [ChoiceDescription]::new('&List', 'List snapshots')
    $create = [ChoiceDescription]::new('&Create', 'Create a new snapshot')
    $activate = [ChoiceDescription]::new('&Activate', 'Activate a snapshot (deactivates live Filespace)')
    $filespace = [ChoiceDescription]::new('&Filespace', 'Activates your live Filespace (deactivates a snapshot)')
    $delete = [ChoiceDescription]::new('&Delete', 'Delete a snapshot')
    $quit = [ChoiceDescription]::new('&Quit', 'Exit')

    $options = [ChoiceDescription[]]($list, $create, $activate, $filespace, $delete, $quit)

    $result = $host.ui.PromptForChoice($Title, $Question, $options, 0)

    switch ($result) {
        0 {List}
        1 {Create}
        2 {Activate}
        3 {Filespace}
        4 {Delete}
        5 {exit}

function List {
Lucid.exe snapshot 

function Create {
$name = Read-Host -Prompt 'Provide snapshot name' 
Lucid.exe snapshot --create $name

function Activate {
Lucid.exe snapshot 
$id = Read-Host -Prompt 'Activate snapshot with ID' 
Lucid.exe activate --snapshot $id

function Filespace {
Lucid.exe activate

function Delete {
Lucid.exe snapshot 
$id = Read-Host -Prompt 'Delete snapshot by ID' 
Lucid.exe snapshot --delete $id

Menu -Title 'Manage your Filespace snapshots' -Question 'What would you like to do?'

Was this article helpful?

0 out of 0 found this helpful