Quantcast
Channel: SQL Server High Availability and Disaster Recovery forum
Viewing all articles
Browse latest Browse all 4689

Powershell Command to Failover Cluster

$
0
0

Hi Guys,

I am still learning Powershell. I have a requirement to Create a PowerShell Command to Failover Everything Running on a Node A Over to Node B. 

I will be having List of Such Nodes in a File.txt file and this powershell command should run on each Node and Failover Anything running on this Node over to another Node. Lets say it will always be Two node( NodeA and NodeB) cluster.

Here is command I am trying:

#FreeNode
$SrvNames = Get-Content -Path 'C:\PS\SrvList.txt'
foreach ($Server in $SrvNames)
{
invoke-command -computername $Server -ScriptBlock { Get-ClusterNode $Server | Get-ClusterGroup | Move-ClusterGroup}
}

SrvList.Txt will have List of Servers such as Server1, Server2, Server3....

Thanks,


Kindly mark the reply as answer if they help


Viewing all articles
Browse latest Browse all 4689

Trending Articles