Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This script creates a backup of the DataCore SANsymphony-V configuration.
No parameters needed. Just execute the script.
This script creates a backup of the DataCore SANsymphony-V configuration.
Author: Patrick Terlisten,, Twitter @PTerlisten
This script is provided “AS IS” with no warranty expressed or implied. Run at your own risk.
This work is licensed under a Creative Commons Attribution NonCommercial ShareAlike 4.0
International License (
# Register DataCore Cmdlets
Import-Module 'C:\Program Files\DataCore\SANsymphony\DataCore.Executive.Cmdlets.dll' -WarningAction silentlyContinue
# To create an encrypted password file, execute the following command
# Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File securestring.txt
# Be sure to set $$ScriptFolder to the folder where the script is located.
# Variables
$BackupFolder = 'C:\SSVBACKUP'
$ScriptFolder = 'C:\Scripts'
$DcsLoginServer = HOSTNAME.EXE
$DcsUserName = 'Administrator'
$DcsPassword = Get-Content $ScriptFolder\securestring.txt | ConvertTo-SecureString
$DcsCredItem = New-Object -Typename System.Management.Automation.PSCredential -Argumentlist $DcsUserName, $DcsPassword
$Keep = 3
# Connect to Server Group using $server
Connect-DcsServer -Server $DcsLoginServer -Credential $DcsCredItem -Connection $DcsLoginServer
# Rotate backup files
ForEach ($Dcs in (Get-DcsServer)) {Invoke-Command -ComputerName $Dcs -ScriptBlock {
# Keep last x files - see $Keep for number of files to keep
# $Files is a variable which stores the filenames of all files that match *.cab
$Files = Get-ChildItem -Path $using:BackupFolder -Recurse | Where-Object {-not $_.PsIsContainer} | where {$ -like '*.zip'}
# Remove old files
$Files | Sort-Object CreationTime | Select-Object -First ($Files.Count - $using:Keep)| Remove-Item
# Set Backupfolder
ForEach ($Dcs in (Get-DcsServer)) {Set-DcsBackUpFolder -Server $Dcs -Folder $BackupFolder}
# Take Configbackup
# Disconnect Server Group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.