PowerShell script to see HA Drives state

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

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

Post Reply
User avatar
vmoskalenko
Posts: 7
Joined: Wed Dec 16, 2015 10:00 am

Wed Jan 27, 2016 5:51 pm

Hi,

I want to share simple PowerShell script to see the current state of HA Drives
This script based on StarWind example, but simplified.

Code: Select all

$server = New-SWServer -host ecvpsql1bshr -user root -password starwind -port 3261
$server.Connect()
if ( $server.Connected )
{ 
    write-host "Devices:"
    foreach($device in ($server.Devices | where {$_.deviceType -eq 'HA Image'}))
    {
        $syncState = $device.GetPropertyValue("ha_synch_status")
        $syncPercent = $device.GetPropertyValue("ha_synch_percent")
        switch($syncState)
        {
            1 {$deviceState = 'Synchronized'}
            2 {$deviceState = 'Synchronizing'}
            3 {$deviceState = 'Not synchronized'}
            default {$deviceState = 'Unknown state'}
        }
        Write-Host $device.TargetName "$deviceState ($syncPercent%)" -ForegroundColor Yellow
    }
    
    $server.Disconnect()
}
User avatar
darklight
Posts: 185
Joined: Tue Jun 02, 2015 2:04 pm

Wed Feb 03, 2016 4:36 pm

Thanks!

I would add some shell input request for -host ecvpsql1bshr instead of hard coding but anyways, good job!
User avatar
anton (staff)
Site Admin
Posts: 4021
Joined: Fri Jun 18, 2004 12:03 am
Location: British Virgin Islands
Contact:

Sat Feb 06, 2016 4:44 pm

@vmoskalenko

is this your script here:

https://powershellmonitoringscript.codeplex.com

If yes you can write a simple article describing what you do and we'll post it, your PoSh script and some other info on our blog here:

https://blog.starwindsoftware.com

...to help you in getting some more PR ;)

Please PM me if interested. Thanks!
Regards,
Anton Kolomyeytsev

Chief Technology Officer & Chief Architect, StarWind Software

Image
Post Reply