Page 1 of 1
Missing Powershell Scripts
Posted: Fri Jan 19, 2018 4:10 pm
by pbosley1322
I just recently installed Starwind VSAN 8 and I do not the GetHASyncStatus Powershell script that is mentioned throughout the documentation and support forums. Where can I get it?
Thanks,
Patrick
Re: Missing Powershell Scripts
Posted: Fri Jan 19, 2018 8:31 pm
by Boris (staff)
It is a part of your StarWind installation.
The default path is "C:\Program Files\StarWind Software\StarWind\StarWindX\Samples\powershell\GetHASyncState.ps1"
Re: Missing Powershell Scripts
Posted: Fri Jan 19, 2018 8:52 pm
by pbosley1322
I am looking in that path, it is not there. I even downloaded the installer and installed on another test host to see if the script would be present. It was not. Here is an LS of my powershell script sample directory.
Directory: C:\Program Files\StarWind Software\StarWind\StarWindX\Samples\powershell
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/20/2017 2:04 PM 840 AddVirtualTape.ps1
-a---- 11/20/2017 2:04 PM 5076 CreateHA(three nodes).ps1
-a---- 11/20/2017 2:04 PM 4234 CreateHA(two nodes).ps1
-a---- 11/20/2017 2:04 PM 4316 CreateHA_LSFS.ps1
-a---- 11/22/2017 6:01 PM 608 CreateImageFile.ps1
-a---- 11/20/2017 2:04 PM 1446 CreateLSFS.ps1
-a---- 11/20/2017 2:04 PM 928 CreateRam.ps1
-a---- 11/20/2017 2:04 PM 1598 CreateSnapshot.ps1
-a---- 11/20/2017 2:04 PM 3088 CreateVirtualTapeLibrary.ps1
-a---- 11/20/2017 2:04 PM 409 enumDevicesTargets.ps1
-a---- 11/20/2017 2:04 PM 1192 ExtendDevice.ps1
-a---- 11/20/2017 2:04 PM 762 FlushCache.ps1
-a---- 12/1/2017 8:54 PM 1384 FlushCacheAll.ps1
-a---- 11/20/2017 2:04 PM 301 getNumaNodes.ps1
-a---- 11/22/2017 6:01 PM 669 haSyncPriority.ps1
-a---- 11/20/2017 2:04 PM 934 InsertVirtualTape.ps1
-a---- 12/1/2017 8:54 PM 424 InstallLicense.ps1
-a---- 11/20/2017 2:04 PM 574 RemoveDevice.ps1
-a---- 11/20/2017 2:04 PM 382 RemoveHAPartner.ps1
-a---- 11/20/2017 2:04 PM 1572 RemoveSnapshot.ps1
-a---- 11/20/2017 2:04 PM 596 RemoveTarget.ps1
-a---- 11/20/2017 2:04 PM 920 RemoveVirtualTape.ps1
-a---- 12/1/2017 8:54 PM 1548 runall.ps1
-a---- 11/20/2017 2:04 PM 2509 Samples.pssproj
-a---- 11/20/2017 2:04 PM 659 SyncHaDevice.ps1
-a---- 11/20/2017 2:04 PM 2997 SyncHaDeviceAdvanced.ps1
-a---- 1/14/2018 3:34 PM 579 SyncStatus.ps1
Patrick
Re: Missing Powershell Scripts
Posted: Fri Jan 19, 2018 9:23 pm
by tig_jeff
Have you looked at the script names "SyncStatus.ps1"?
Re: Missing Powershell Scripts
Posted: Fri Jan 19, 2018 9:35 pm
by pbosley1322
LOL, that is a script that I wrote based off one of the other ones. The date stamp gives it away. I thought I moved all of my modified scripts to another directory, I obviously missed one. - Patrick
Re: Missing Powershell Scripts
Posted: Sat Jan 20, 2018 3:48 pm
by Boris (staff)
Here is the script from the StarWindX samples:
Code: Select all
#
# This following example shows how to get synchronization status of specified HA device and
# if there is a need run synchronization
#
Import-Module StarWindX
try
{
#
# connect to the server
#
$server = New-SWServer -host 192.168.1.155 -port 3261 -user root -password starwind
$server.Connect()
#
# Try to find specified device
#
$deviceName = "HAImage1"
$partnerTargetName = "iqn.2008-08.com.starwindsoftware:192.168.1.156-partnerha1"
$deviceFound = $false
foreach($device in $server.devices)
{
if ($device.name -eq $deviceName)
{
Write-Host "$($deviceName)" -foreground yellow
Write-Host ""
$deviceFound = $true
$syncState = $device.GetPropertyValue("ha_synch_status")
while ($syncState -ne "1")
{
#
# Device not synchronized. Maybe it waiting for autosynchronization ?
#
$waitForAutoSync = $device.GetPropertyValue("ha_wait_on_autosynch")
if ( $waitForAutoSync -eq "1" )
{
Write-Host "Waiting for autosynchronization..." -foreground yellow
}
else
{
if ( $syncState -eq "2" )
{
#
# Device is synchronizing. Get synchronization percent and show it
#
$syncPercent = $device.GetPropertyValue("ha_synch_percent")
Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow
}
if ( $syncState -eq "3" )
{
#
# Device not synchronized. Synchronize current node from partner
#
Write-Host "Device not synchronized. Synchronize current node from partner '$($partnerTargetName)'" -foreground yellow
$params = new-object -ComObject StarWindX.Parameters
$params.AppendParam("deviceID",$device.DeviceId)
$params.AppendParam("partnetTargetName",$partnerTargetName)
$server.ExecuteCommand( 0, "restoreHAPartnerNode", $params)
#
# If you want to synchronize partners from current node you can comment out code above and uncomment section below
#
#
# Device not synchronized. Mark current node as 'Synchronized'.
# WARNING, Command changes Device Status to "Synchronized" without Data Synchronization with HA (High Availability) Partner,
# Device will start processing Client Requests immediately and will be used as Data Synchronization Source for Partner Device.
#
#Write-Host "Device not synchronized. Mark current node as 'Synchronized'. " -foreground yellow
#$params = new-object -ComObject StarWindX.Parameters
#$params.AppendParam("deviceID",$device.DeviceId)
#$server.ExecuteCommand( 0, "restoreCurrentHANode", $params)
Start-Sleep -m 5000
}
}
#
# Refresh device info
#
$device.Refresh()
Start-Sleep -m 1000
$syncState = $device.GetPropertyValue("ha_synch_status")
}
Write-Host "Synchronization Status: Synchronized" -foreground yellow
break;
}
}
if ( $deviceFound -ne $true )
{
Write-Host "$($deviceName) not found" -foreground red
}
}
catch
{
Write-Host "Exception $($_.Exception.Message)" -foreground red
}
$server.Disconnect( )
Re: Missing Powershell Scripts
Posted: Sat Jan 20, 2018 5:30 pm
by tig_jeff
Here is mine...
--- START ---
#
# This following example shows how to get synchronization status of specified HA device and
# if there is a need run synchronization
#
Import-Module StarWindX
try
{
#
# connect to the server
#
# YOUR IP ADDRESS WOULD REPLACE X.X.X.X...
$server = New-SWServer -host X.X.X.X -port 3261 -user root -password starwind
$server.Connect()
#
# Try to find specified device
#
# YOUR DEVICE NAME GOES HERE...
$deviceName = "HAImage1"
# YOUR iSCSI PARTNER TARGET GOES HERE...
$partnerTargetName = "iqn.2008-08.com.starwindsoftware:192.168.64.40-partnerha1"
$deviceFound = $false
foreach($device in $server.devices)
{
if ($device.name -eq $deviceName)
{
Write-Host "$($deviceName)" -foreground yellow
Write-Host ""
$deviceFound = $true
$syncState = $device.GetPropertyValue("ha_synch_status")
while ($syncState -ne "1")
{
#
# Device not synchronized. Maybe it waiting for autosynchronization ?
#
$waitForAutoSync = $device.GetPropertyValue("ha_wait_on_autosynch")
if ( $waitForAutoSync -eq "1" )
{
Write-Host "Waiting for autosynchronization..." -foreground yellow
}
else
{
if ( $syncState -eq "2" )
{
#
# Device is synchronizing. Get synchronization percent and show it
#
$syncPercent = $device.GetPropertyValue("ha_synch_percent")
Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow
}
if ( $syncState -eq "3" )
{
#
# Device not synchronized. Synchronize current node from partner
#
Write-Host "Device not synchronized. Synchronize current node from partner '$($partnerTargetName)'" -foreground yellow
$params = new-object -ComObject StarWindX.Parameters
$params.AppendParam("deviceID",$device.DeviceId)
$params.AppendParam("partnetTargetName",$partnerTargetName)
$server.ExecuteCommand( 0, "restoreHAPartnerNode", $params)
#
# If you want to synchronize partners from current node you can comment out code above and uncomment section below
#
#
# Device not synchronized. Mark current node as 'Synchronized'.
# WARNING, Command changes Device Status to "Synchronized" without Data Synchronization with HA (High Availability) Partner,
# Device will start processing Client Requests immediately and will be used as Data Synchronization Source for Partner Device.
#
#Write-Host "Device not synchronized. Mark current node as 'Synchronized'. " -foreground yellow
#$params = new-object -ComObject StarWindX.Parameters
#$params.AppendParam("deviceID",$device.DeviceId)
#$server.ExecuteCommand( 0, "restoreCurrentHANode", $params)
Start-Sleep -m 5000
}
}
#
# Refresh device info
#
$device.Refresh()
Start-Sleep -m 1000
$syncState = $device.GetPropertyValue("ha_synch_status")
}
Write-Host "Synchronization Status: Synchronized" -foreground yellow
break;
}
}
if ( $deviceFound -ne $true )
{
Write-Host "$($deviceName) not found" -foreground red
}
}
catch
{
Write-Host "Exception $($_.Exception.Message)" -foreground red
}
$server.Disconnect( )
--- END ---
If you look at one of my other threads you will see me use this script (or a modified version of it) to show status.
You can see an image of it, in action, in my HOW-TO.
Hope this helps.
Re: Missing Powershell Scripts
Posted: Mon Jan 22, 2018 8:52 am
by Boris (staff)
pbosley1322,
You can use any of them, either the sample script or the customized one offered by tig_jeff.