StarWind and Powershell

Software-based VM-centric and flash-friendly VM storage + free version

Moderators: anton (staff), art (staff), Max (staff), Anatoly (staff)

Post Reply
MBerthe
Posts: 11
Joined: Wed Nov 18, 2009 6:20 pm

Sun Apr 12, 2020 12:54 pm

Hi,
I refresh my Home lab during this containment period.
I would like to deploy and configure StarWind with Powershell.
On a Windows 2019 test server, I have deployed a StarWind Virtual San Free V8.0.13481.
I try to found a tech document on managing StarWind with Powershell. The only documents I found are the PDFs on the C:\Program Files\StarWind Software\StarWind\StarWindX\Help. Those documents are very light. If found a reference to a StarWindX.chm but I don't find it.
So I try the Get-Help, but it seems that there is a issue to list all functions. The list stop on Get-SWXInstance.

Code: Select all

PS C:\Windows\system32> get-help starwindx

Name                              Category  Module                    Synopsis
----                              --------  ------                    --------
Add-HADevice                      Function  StarWindX                 Creating New High Availability Device
Add-IBVDevice                     Function  StarWindX                 Creating new thin-provisioned virtual device
Add-ImageDevice                   Function  StarWindX                 Creating a new virtual device (ImageFile device).
Add-RamDevice                     Function  StarWindX                 Creating a RAM disk
Add-VirtualTape                   Function  StarWindX                 Add a new Virtual Tape to the existing Virtual Tape Library
Add-VirtualTapeLibrary            Function  StarWindX                 Creates a Virtual Tape Library
Enable-SWXLog                     Function  StarWindX                 Enable StarWindX log
Get-SWXInstance                   Function  StarWindX                 Get StarWindX object instance
Can somebody help me?
Take care.
Mathieu
MBerthe
Posts: 11
Joined: Wed Nov 18, 2009 6:20 pm

Sun Apr 12, 2020 6:09 pm

Hi
I found light information with Get-command -Module *Starwind*.
But, I don't found information about properties and method.
For example, I would like to attach a device to a target.
I found that a target have a method AttachDevice but I don't find how to use it.
The script below work but the line $target.AttachDevice($Device) return nothing (no error) but do nothing.

Code: Select all

foreach ($ExistingTarget in $Server.Targets){
	if ($ExistingTarget.Alias -eq $TargetAlias){
		$TargetExists=$true
		$target=$ExistingTarget
	}
}
If (!$TargetExists) {
	$target = New-Target -server $Server -alias $TargetAlias  -clustered $MultipleiSCSICconnections
}
New-ImageFile -server $server -path $filePath -fileName $fileName -size $Size
$Device = Add-ImageDevice -server $Server -path $filePath -fileName $fileName -sectorSize $sectorSize -NumaNode $numaNode -CacheMode $cacheMode -CacheSize $cacheSize
$target.AttachDevice($Device)
Please help me :?
Have a nice day
yaroslav (staff)
Staff
Posts: 2361
Joined: Mon Nov 18, 2019 11:11 am

Mon Apr 13, 2020 4:23 am

Hello,
For example, I would like to attach a device to a target.
Please note that adding multiple devices to one target might end badly. To fix your issue, it is necessary to see the StarWind.cfg file to see if targets and devices were created right. Check if the

Code: Select all

<target name=
section at the end of the StarWind.cfg has 1 device associated with 1 target. Let me know if something is wrong with targets.
You can use the CreateHA script instead. Find here how that can be done https://www.starwindsoftware.com/help/H ... ategy.html. There are versions of script for a 2- and 3-node clusters.
So, please, remove the old HA devices, and create new ones using the script and the guide that I shared above.
That script creates target, attaches a HA device to it, and presents it over the network to the partner.

On top of that, could you share the entire script with the community? It would be cool to see the entire script.

Let me know if there is anything I can assist you with.
MBerthe
Posts: 11
Joined: Wed Nov 18, 2009 6:20 pm

Mon Apr 13, 2020 9:43 am

Hi,
Thanks for your help.
I have check all script in C:\Program Files\StarWind Software\StarWind\StarWindX\Samples\powershell and read a lot of article in the help https://www.starwindsoftware.com/help.
I found also examples on GitHub https://github.com/search?p=2&q=StarWindX&type=Code
I'll share the script at the end of my StarWind powershell deep dive :D
Yaroslav, can you explain
Please note that adding multiple devices to one target might end badly.
?
Have a nice day.
yaroslav (staff)
Staff
Posts: 2361
Joined: Mon Nov 18, 2019 11:11 am

Mon Apr 13, 2020 10:16 am

Hi,

If there are multiple HA devices associated with 1 target some of them will not work at all (1 still may work, others will be throwing some warnings). It is necessary to use HA 1 device per target. Well, if you already have multiple devices associated with one target, share the config file in PM I'll see what I can do with it. Please make sure to save a backup of StarWind.cfg before handing it to me.
I'll share the script at the end of my StarWind powershell deep dive :D
Can't wait to see it :)
$target.AttachDevice($Device)
It does nothing because it does not declare anything. In other words, you do not have = after it, so it declares nothing. Hope you got my point. https://docs.microsoft.com/en-us/powers ... wershell-7 here is more about that operator.

To create a HA device and replicate use the CreateHA script. Well, if you are building something own out of those scripts, let me know if there's something else we can help you with. Please note that we cannot prepare a custom script for you. However, I guess we can guide you :wink:
MBerthe
Posts: 11
Joined: Wed Nov 18, 2009 6:20 pm

Mon Apr 13, 2020 11:22 am

Hi,
For the moment, I don't have HA. I have only one server and I try to manage all settings by Powershell.
I have a project with a customer to deploy 4 clusters from 2 to 8 node On Windows Server 2019 and StarWind V8. This is why I would like to manage everything by PowerShell.

For your information, the method AttachDevice of the Target object need the device name not the device object. So the right syntax is

Code: Select all

$target.AttachDevice($Device.Name)
Now it's works :wink: but I have to change my methodology to let one target with only one device.

Is it possible to get the file StarWindX.chm?
Thanks
yaroslav (staff)
Staff
Posts: 2361
Joined: Mon Nov 18, 2019 11:11 am

Mon Apr 13, 2020 1:58 pm

Hi,

Thanks for the info. Guess I missed that. Well, happy to know that it finally works!
StarWindX.chm has gone missing from the recent build for some reason. No worries, here are the files. *.chi one is an index.
Attachments
StarWindX.rar
Here are chm and chi files.
(395.36 KiB) Downloaded 308 times
MBerthe
Posts: 11
Joined: Wed Nov 18, 2009 6:20 pm

Thu Apr 16, 2020 1:58 pm

Thanks Yaroslav :)
This help file is more for .Net developer.
Can you ask for create a more Powershell oriented help?
yaroslav (staff)
Staff
Posts: 2361
Joined: Mon Nov 18, 2019 11:11 am

Thu Apr 16, 2020 2:42 pm

Could you kindly tell me what kind of info you expect to see so that I could file the feature request?
Post Reply