Control Datacore SSV Write Cache with APC PCNS
When deploying a Software Defined Storage solution like Datacore SAN Symphony V, SSV, which uses volatile memory for write caching, it is important to make sure that this cached data is not lost when a hardware failure occurs.In a mirrored configuration, a write is acknowledged only when the data is successfully stored in the write cache of the mirrored pair hosts. When one of the hosts is offline, write caching is disabled and disks are put in write through mode. See Write Caching in the Virtual Disks article. Write caching is enabled again once all participating nodes are up and running again.
When a SSV node is attached to a UPS it is important to configure the node to disable write cache as soon as the UPS losses input power and starts running on battery power. SSV will do this automatically when a supported UPS is connected directly, Serial/USB, with the SSV node. Although your APC UPS may be complaint when connected via USB or Serial, it will not be detected as a UPS when using the UPS network interface card. This is PCNS is only an agent application that communicates with the UPS over the network. No drivers are installed for the O/S to detect the UPS.
The Datacore SSV UPS Support article states that for non-compliant UPS’s the write caching needs to be disabled manually.
Below you will find the procedure to disable write caching when the UPS is on Battery power and to enable it again should power be restored before the server shuts down.
Note that, if the datacore node shuts down properly, upon powering on the datacore services will enable write caching unless the services were manually stopped before the shutdown. Please check the UPS support article linked earlier.
It will be assumed that PCNS is already installed on the SSV node and that PCNS can communicate with the APC network card.
I would like to start by thanking Patrick Terlisten for his Backup DataCore SANsymphony-V config using PowerShell blog post as the scripts have been assembled by using some of his methods.
Preparation
Both scripts use an encrypted string to encrypt the Dscadmin password. The string is stored in upssecurestring.txt
The powershell command to encrypt the password and store it in the txt file is:
1 | Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File upssecurestring.txt |
The issue is that the password will only be decrypted if the script is executed with the same user that encrypted it. This is a problem the PCNS service logs on with the local system account. There are ways around this but I would suggest leaving the service to log on as the local system account. What we will do instead is to generate the secure string from the local system account.
The procedure to run a command as a SYSTEM user is described in this Ask the Directory Services Team Blog post.
- As described in the ADST blog you will need to download Windows Sysinternal’s PSTools.
- Extract the tools and open an elevated command prompt.
- Navigate to the folder you extracted the PStools
- Run the command PSexec -s -i -d powershell.exe and a new powershell window will open
- Check that the powershell console is running with the nt authority\system account by running whoami /user
- Navigate to the folder where the datacore scripts will be located Eg. C:\Datacore_Scripts\
- Execute Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File upssecurestring.txt
- Type Dcsadmin account password and press Enter

Encrypt Dcsamin Password as SYSTEM account
The password will be saved in an encrypted form in the upssecurestring.txt file.
You will also need to allow the service to interact with desktop. Once the setting has been changed, you will need to restart the PowerChute Network Shutdown Service.

PowerChute Network Shutdown Service Properties
The below Enable/Disable write cache scripts should execute without issues when trigger with PCNS
Disable Write Cache
The below script will disable write cache and set a Log Message in SSV that the Write Cache has been disabled. Some of the variables may need to be altered to meet your environment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 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 upssecurestring.txt # Be sure to set $ScriptFolder to the folder where the script is located. # Variables $ScriptFolder = "C:\Datacore_Scripts" $DcsLoginServer = "localhost" $DcsUserName = "dcsadmin" $DcsPassword = Get-Content $ScriptFolder\upssecurestring.txt | ConvertTo-SecureString $DcsCredItem = New-Object -Typename System.Management.Automation.PSCredential -Argumentlist $DcsUserName, $DcsPassword # Connect to Server Group using $server Connect-DcsServer -Server $DcsLoginServer -Credential $DcsCredItem -Connection $DcsLoginServer Add-DcsLogMessage -Message "Server is running on UPS Battery and write caching will be DISABLED." -Level Warning -PostAlert #Disable Write Cache Get-DcsServer | Disable-DcsServerWriteCache Disconnect-DcsServer |
Save the powershell script file to “Disable-Write-Cache.ps1″ in the scripts folder
PCNS requires a CMD or BAT file to execute so we will need to create a bat file Eg. UPSONBATTERY.BAT and put the following in it
1 | powershell.exe -file "C:\Datacore_Scripts\Disable-Write-Cache.ps1" |
Next we need to configure PCNS to execute the command when the UPS is on battery:
- Open PCNS User Interface and login
- Click on Configure Events and click on the settings icon in the Command File column located in the UPS on Battery row
- Click on the Enable Command File check box and set the Delay. I leave it a 0s to run the command as soon as the event occurs.
- In the Full path to command file field type the path to the batch file created earlier
- Click on apply

Configure Run Command File for UPS On Battery Event
Enable Write Cache
When power is restored, it is beneficial to enable the write cache again to return to the expected performance levels.
The script below will enable the write cache and add a log entry in SSV that the write cache has been enabled.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 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 upssecurestring.txt # Be sure to set $$ScriptFolder to the folder where the script is located. # Variables $ScriptFolder = "C:\Datacore_Scripts" $DcsLoginServer = "localhost" $DcsUserName = "dcsadmin" $DcsPassword = Get-Content $ScriptFolder\upssecurestring.txt | ConvertTo-SecureString $DcsCredItem = New-Object -Typename System.Management.Automation.PSCredential -Argumentlist $DcsUserName, $DcsPassword # Connect to Server Group using $server Connect-DcsServer -Server $DcsLoginServer -Credential $DcsCredItem -Connection $DcsLoginServer Add-DcsLogMessage -Message "Server is NOT running on UPS Battery and write caching will be ENABLED." -Level Warning -PostAlert #Enable Write Cache Get-DcsServer | Enable-DcsServerWriteCache Disconnect-DcsServer |
Save the above script to your Datacore Scripts folder as Enable-Write-Cache.ps1
Now we need to create the batch file to be executed when the event occurs, UPSONPOWER.bat
1 | powershell.exe -file "C:\Datacore_Scripts\Enable-Write-Cache.ps1" |
Next we need to configure PCNS to trigger on the event Input Power Restored:
- Open PCNS User Interface and login
- Click on Configure Events and click on the settings icon in the Command File column located in the Input Power Restored row
- Click on the Enable Command File check box and set the Delay. I leave it a 0s to run the command as soon as the event occurs.
- In the Full path to command file field type the path to the batch file created earlier
- Click on apply

Configure Run Command File for UPS Input Power Restored Event
Configuring Notifications
If you want to receive an e-mail notification when the write cache setting is changed, you can do so by adding a task in the SSV Management console
- Click on the Tasks icon and click on create task.
- Set a task name Eg. Write Cache Notification and click Next
- Trigger on Select
- Log Message posted
- In the define filter select Message Text and contains. In the next field type write caching and click Add Filter
- Click Next
- In Perform Action select Send an email and choose the desired recipient and click Next and the Finish
When the events are triggered, the recipient will receive an e-mail similar to the below:

Write Cache Notification E-mail
Let me know in the comments section if you found it useful or if you need further clarifications. Any Feedback is welcome.
Hi Brian,
nice work! 🙂
Regards,
Patrick
Thanks Patrick! 🙂
[…] the encrypted password file under that account. This can be done by following the procedure found here by using PSExec. You will also need to set-up the Powerchute Agent Service to Allow Service to […]
On one of my servers, I’m getting:
Connect-DcsServer : The caller was not authenticated by the service.
At C:\Datacore_Scripts\Disable-Write-Cache.ps1:17 char:1
+ Connect-DcsServer -Server $DcsLoginServer -Credential $DcsCredItem -Connection $ …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-DcsServer], SecurityNegotiationException
+ FullyQualifiedErrorId : 33,DataCore.Executive.PowerShell.ConnectServerCmdlet
I’ve tried recreating the encrypted file to no avail. thoughts? Hopefully you’re still watching this thread.
Hey Brian,
First I would run the script or at least connect to the local Datacore server(localhost) and supply the credentials manually to confirm the credentials are working correctly.
If they do work, check the service settings again and recreate the encrypted password file using the psexec method.
Make sure to generate the file on each host and not copy it from one host to the other. This maybe obvious but I am mentioning it just in case.
I am assuming you have other servers on which the script is working properly. If yes this would indicate that there is some mismatch somewhere.
Hope I was able to help you.
Let us know 🙂
Thanks for the response. I did work this out and it was simply that something was awry on the server. Rebooted and recreated files and it’s all good.
Thanks!
Super! Thanks for keeping us updated