I have never written a script and i have to find one that will failover to second server if first goes down. Does anyone have a way i can start this?
$remoteComputer = "dtdbtest01"IF (Test-Connection -BufferSize 32 -Count 1 -ComputerName $remoteComputer -Quiet)
got this to work so i know if server is up or down.
You don't give any details as to what this failover is all about, SQL, file Server, Werb Server, etc.You don't need a script for such things.This is what cluster server managers are for. e.g, Microsoft Cluster Services.
As for this, $remoteComputer = "dtdbtest01"IF (Test-Connection -BufferSize 32 -Count 1 -ComputerName $remoteComputer -Quiet)
This just tells you if the server is respnding, not whether your target services are actaully running / reachable.
You can use Group Policy Prefrerences to monitor and restart services and use Task Schedular to notify you of events you are interested in.
I am a huge PowerShell evangilist teacher, architect, DevOps person by all my job roles, but PowerShell is just a tool, the the right tool for everything. Use the enterprise features of the OS first and if that does not satisfy the use case, the consider getting creative with PowerShell or other tools.
KNow that there are probaly already script written to get you going. E.g.,
Use PowerShell to monitor Windows services
This script is used to monitor services. The script will restart the service(s) three times with the third time also generating an email message to a list of users. The script will also insure that the service(s) is set to Autostart. The script can be ran as a scheduled task. The
Yet, if you are not a scripter then they may not make sense to you. Never, ever run a script in your environment you do not fully understand exactly what it is doing. You could distroy your entire network.
There are tons for no cost learning assistance all over the web. E.g.
Powered by IDERA