Page 1 of 1

PowerShell script to see HA Drives state

Posted: Wed Jan 27, 2016 5:51 pm
by vmoskalenko
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()
}

Re: PowerShell script to see HA Drives state

Posted: Wed Feb 03, 2016 4:36 pm
by darklight
Thanks!

I would add some shell input request for -host ecvpsql1bshr instead of hard coding but anyways, good job!

Re: PowerShell script to see HA Drives state

Posted: Sat Feb 06, 2016 4:44 pm
by anton (staff)
@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!