Page 1 of 1

How to retrieve HA Device Serial-Id via powershell?

Posted: Sat Dec 08, 2018 9:13 pm
by serhiogo
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

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Sun Dec 09, 2018 8:07 am
by Boris (staff)
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.

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Sun Dec 09, 2018 9:59 am
by serhiogo
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

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Sun Dec 09, 2018 10:32 am
by Boris (staff)
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.

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Sun Dec 09, 2018 7:57 pm
by serhiogo
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

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Sun Dec 09, 2018 9:17 pm
by Boris (staff)
Nice to hear I was able to push you to the right direction.

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Tue Apr 14, 2020 6:32 pm
by MBerthe
Hi,
I wrote a little tricky PS script already, thanx again =]
serhiogo, can you share your script?
Thanks a lot. :D

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Thu Apr 16, 2020 1:53 pm
by MBerthe
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

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Tue Apr 21, 2020 5:26 pm
by Michael (staff)
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.

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Tue Apr 28, 2020 6:55 pm
by MBerthe
Hi Michael,
I have already manage this null characters in my code with

Code: Select all

-replace "`0",""
Thanks for your reply, take care

Re: How to retrieve HA Device Serial-Id via powershell?

Posted: Wed Apr 29, 2020 3:54 pm
by yaroslav (staff)
MBerthe,

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