Jump to content

Noob Question on whether AutoIt is suitable


MrCrispy
 Share

Recommended Posts

Hi All

Extremely new to Autoit and my first task is to see if it's going to suitable for a job I need it to do...

I work for for an MSP, and we have 1000+ servers (mainly Windows) and I'm looking for something to automate the power down of our windows boxes. We have multiple customers, some might have only 5 servers, others might have 40+ and what I'm after doing is create some sort of work flow of dependency to shut down the Windows O/S on the servers e.g. shut down the web servers first, then app servers, then db servers.

I'm thinking along the lines of;

1. Shut down server A

2. Wait until server A is down (ping it?)

3. Shut down servers B & C

4. Wait until servers B & C are down

5. Shutdown server D

6. Wait until server D is down

7. Complete!

Thanks for any advice

J

Link to comment
Share on other sites

I would use PSShutdown from Sysinternals:

http://technet.microsoft.com/en-us/sysinte...s/bb896649.aspx

PSShutdown("\\ServerA")
If @ERROR Then
    MsgBox(0,"Error","ServerA failed to shutdown")
    Exit
EndIf

PSShutdown("\\ServerB")
If @ERROR Then
    MsgBox(0,"Error","ServerB failed to shutdown")
    Exit
EndIf

PSShutdown("\\ServerC")
If @ERROR Then
    MsgBox(0,"Error","ServerC failed to shutdown")
    Exit
EndIf

PSShutdown("\\ServerD")
If @ERROR Then
    MsgBox(0,"Error","ServerD failed to shutdown")
    Exit
EndIf

Func PSShutdown($sComputer)
    $result = RunWait(StringFormat("psshutdown.exe %s -f -k", $sComputer))
    If $exit_code = 1 Then ;Exit code 1 = SUCCESS
        ;Wait until server goes down
        Do
            $ping = Ping($sComputer)
            Sleep(500)
        Until $ping = 0
    Else
        Return SetError(1,0,0)
    EndIf
    Return SetError(0,0,0)
EndFunc

I'm not sure that Ping() supports double backslashes in the hostname, you may have to strip those with StringReplace or just use the IP address of each server.

Edited by weaponx
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...