Quantcast
Channel: High Availability (Clustering) forum
Viewing all articles
Browse latest Browse all 5654

Script Not Working in Cluster

$
0
0

I'm trying to understand why the script I have setup isn't working properly. It appears to work fine outside of the cluster but doesn't kill the processes I'm wanting to kill.

I have a service I want to start.  The service spawns processes.  When I fail over I want to stop the service and kill the processes on the other nodes.

Import-Module failoverclusters

$localhost = $env:computername
$clustergroup = Get-ClusterGroup -Name FTP
$othernodes = Get-ClusterNode | ?{$_.Name -ne $clustergroup.OwnerNode.Name}

do
{
"Started"
#Stop the services running on all members in the cluster
    foreach ($node in $othernodes){
        Get-Service -ComputerName $node.Name -Name ftp.get | ?{$_.Status -eq "Running"} | Stop-Service
        Get-WmiObject -ComputerName $node.Name -Class Win32_Process -Filter "Name='FTP.exe'" | ?{$_.CommandLine -like "*C:\ftp\FTP.Get*"} | foreach {$_.Terminate()}
    }

#Start Service On This Node
Get-Service -ComputerName $clustergroup.OwnerNode.Name -Name ftp.get | ?{$_.Status -ne "Running"} | Start-Service

Start-Sleep -Seconds 3600
"Completed"
}
while ($clustergroup.OwnerNode.Name -eq $localhost)


David Jenkins


Viewing all articles
Browse latest Browse all 5654

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>