How to retrieve HA Device Serial-Id via powershell?

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

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

Post Reply
serhiogo
Posts: 30
Joined: Thu Aug 16, 2018 12:49 pm

Sat Dec 08, 2018 9:13 pm

Hello collegues!

Could you pls prompt me how to retrieve HA Device Serial-Id via powershell?
This red-marked one:

Image

This is neither "DeviceId" nor "TargetId" values, and I cannot find it neither in the "$server.Devices" nor in the "$server.Targets" structure output at all...

---------------------
WBR, Serhio Go
Boris (staff)
Staff
Posts: 805
Joined: Fri Jul 28, 2017 8:18 am

Sun Dec 09, 2018 8:07 am

What's your use case that might require this information?
To the best of my knowledge, this is not available in StarWindX, but you can get a workaround for this. You can parse the swdsk file as XML and get the value from header.device.storages.storage.inquiry.serial_id
Let me know whether that fits your needs.
serhiogo
Posts: 30
Joined: Thu Aug 16, 2018 12:49 pm

Sun Dec 09, 2018 9:59 am

Boris (staff) wrote:What's your use case that might require this information?
The Starwind presents its devices to iSCSI clients by this Id.
For example, to the ESXi.

Starwind view:

Image

ESXi view:

Image

If I've got several devices to add (especially having the same size) I can recognize every one only by this Id on the ESXi side.
Boris (staff) wrote:To the best of my knowledge, this is not available in StarWindX, but you can get a workaround for this. You can parse the swdsk file as XML and get the value from header.device.storages.storage.inquiry.serial_id
Let me know whether that fits your needs.
It look like what I seek, thanks.

---------------------
WBR, Serhio Go
Boris (staff)
Staff
Posts: 805
Joined: Fri Jul 28, 2017 8:18 am

Sun Dec 09, 2018 10:32 am

While going with the serial ID the suggested way should be fine, I'd rather prefer working with the target names, for which StarWindX is able to output information. But this can be merely a matter of preference though.
serhiogo
Posts: 30
Joined: Thu Aug 16, 2018 12:49 pm

Sun Dec 09, 2018 7:57 pm

Boris (staff) wrote:While going with the serial ID the suggested way should be fine, I'd rather prefer working with the target names, for which StarWindX is able to output information. But this can be merely a matter of preference though.
It's more comfortable to use target names of course but not in this case. All I see in ESXI for the moment of new datastore mount is Starwind Device Id.

I wrote a little tricky PS script already, thanx again =]

Image


---------------------
WBR, Serhio Go
Boris (staff)
Staff
Posts: 805
Joined: Fri Jul 28, 2017 8:18 am

Sun Dec 09, 2018 9:17 pm

Nice to hear I was able to push you to the right direction.
MBerthe
Posts: 11
Joined: Wed Nov 18, 2009 6:20 pm

Tue Apr 14, 2020 6:32 pm

Hi,
I wrote a little tricky PS script already, thanx again =]
serhiogo, can you share your script?
Thanks a lot. :D
MBerthe
Posts: 11
Joined: Wed Nov 18, 2009 6:20 pm

Thu Apr 16, 2020 1:53 pm

Hi,
If you want to find the serial number of a StarWind Disk, you can use this script part:

Code: Select all

$DeviceToCreateFilePath="My Computer\C\StarWind"
$DeviceToCreateFileName="ImageFile01"
[XML]$ImageFileConfig = (Get-Content -Path "$(($DeviceToCreateFilePath.Substring(("My Computer\").Length)).insert(1,":"))\$($DeviceToCreateFileName).swdsk") -replace "`0",""
$DiskSerialNumber=$ImageFileConfig.header.device.storages.storage.inquiry.serial_id
@StarWind teams, the swdsk file contains null characters. Can you clean the XML file?

Have a nice day
Michael (staff)
Staff
Posts: 317
Joined: Thu Jul 21, 2016 10:16 am

Tue Apr 21, 2020 5:26 pm

MBerthe,
Null characters were added there intentionally and are not going to be removed.
You can remove them if you want but we do not recommend doing it for proper program work.
MBerthe
Posts: 11
Joined: Wed Nov 18, 2009 6:20 pm

Tue Apr 28, 2020 6:55 pm

Hi Michael,
I have already manage this null characters in my code with

Code: Select all

-replace "`0",""
Thanks for your reply, take care
yaroslav (staff)
Staff
Posts: 2279
Joined: Mon Nov 18, 2019 11:11 am

Wed Apr 29, 2020 3:54 pm

MBerthe,

Thanks for the update! Good luck in PowerShell.
Let us know if there is anything else we can assist you with.
Post Reply