Managing StarWind VSAN using PowerShell

What is StarWind VSAN?

StarWind VSAN eliminates any need in physical shared storage by simply mirroring internal hard disks and flash between hypervisor servers. StarWind Virtual SAN delivers performance and reliability using commercial off-the-shelf hardware, removing the need for costly proprietary components.

StarWind Virtual SAN® is entirely software-based, hypervisor-centric virtual machine storage. It creates a fault-tolerant and high-performing storage pool that is built for the virtualization workload “from scratch”. StarWind Virtual SAN® basically “mirrors” inexpensive internal storage between hosts

How to Install StarWind VSAN?

First, you must create a Windows Server based Virtual Machine, install the StarWind EXE on this Windows Server 2016. All the machines are domain joined. Let’s start by downloading the EXE from the following link: https://www.starwindsoftware.com/registration-starwind-virtual-san. You will also receive a TRIAL license key that you must copy on your StarWind server. Run the package and Accept le license agreement.

I wrote an article that describes how to install StarWind VSAN, so please read this article before going deeper: https://get-cmd.com/?p=5028

How to Manage StarWind VSAN?

In order to manage StarWind VSAN, you can use the GUI or Windows PowerShell. In this article, I will explain how to use PowerShell and especially the StarWindX Module.

Once the installation is done, you can start a PowerShell console with the StarWindX module:

Run the following command to confirm that the StarWindX module is loaded:

PS > Get-Module

Now, you can list all the available cmdlets:

PS > Get-Command -Module *Starwind*

Cool!

So, now you can also open a simple PowerShell console and then import the StarWindX module:

PS > Import-Module StarWindX

At this step, you machine is ready to manage your StarWind infrastructure. If don’t know how to manage StarWind, you will notice that a lot of PowerShell scripts are at your disposal. These scripts have been created by the StarWind Team and they are located in the following directory:

c:\Program Files\StarWind Software\StarWind\StarWindX\Samples\powershell

Before going deeper, it is a good idea to open these scripts and check their content.

Managing StarWind VSAN

First of all, we need to get some basic information about our StarWind server. So, the first thing to do is to connect to the server with the New-SWServer cmdlet:

PS > New-SWServer <IP_StarWind_SERVER> <PORT_NUMBER> <LOGIN> <PWD>

By default, the login is ‘root’ and the password is ‘starwind’.

  1. Import the module
  2. Set the StarWind Server information
  3. Connect to the server
  4. Display the result

This script is essential to work with StarWindX. You must be connected before running any cmdlet:

Here, I can notice:

  • The IP and the port number
  • The Targets: I don’t have any target yet
  • The Devices: I don’t have any devices yet
  • ServerInformation: I can see the StarWind version

You can easily filter and get a specific information:

PS > $server.ServerInformation

Licensing

If you have a valid license file, it easy to import this file using PowerShell. Here, I copy/paste my license key in the ‘C:\Temp\’ folder and then use the Set-SWLicense cmdlet:

PS > Set-SWLicense $server <YOUR_LICENSE_FILE>

After running your script, it is still a best practice to run the ‘Disconnect’ command:

PS > $server.Disconnect()

To finish, you can create your targets and devices using PowerShell. To perform these tasks, you can run the following command:

PS > Add-ImageDevice

PS > New-Target

To get more information about the ouput, run the ‘$target’ variable:

Great! A target has been created which is called ‘targetimg1’ with a device called ‘img1’.

If you have more than one target, then you can use the ‘foreach-loop’:

Conclusion

For those of you who are wondering why using PowerShell instead of the GUI, then I can only say: ‘Just for automation’. The StarWind VSAN GUI is nice and very responsive, but sometimes it could be very useful to automate some tasks to save time. StarWind VSAN allows you to manage the infrastructure by command line which is not always the case for the others softwares. Of course, if you just have to create one target, then don’t worry about automation!

Thanks for reading! You can follow me on Twitter @PrigentNico

About Nicolas 282 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.