1 / 30

Automate Everyday Functions

Automate Everyday Functions. Using Old School methods to make life easier. Automate Everyday Functions. Overview Introductions Everyday problems and solutions Security Cameras on the blink Server Status updates Remote Connection Location Resources Other ideas / questions Close.

barny
Download Presentation

Automate Everyday Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Automate Everyday Functions Using Old School methods to make life easier

  2. Automate Everyday Functions Overview • Introductions • Everyday problems and solutions • Security Cameras on the blink • Server Status updates • Remote Connection Location • Resources • Other ideas / questions • Close

  3. Automate Everyday Functions Introduction Russell Ivey – Gilmer ISD (Center, Longveiw, Ore City) Married – dad of 6 – cross country coach Bachelor of Science – ETBU Masters of Education – Texas A&M Programming background Worked in public education for 16 years Problem solver Disclaimer – Still learning daily

  4. Automate Everyday Functions Everyday problems – and solutions We are all problem solvers. Its in our job description. Many times, these are 1 and done fixes; however sometimes we have to solve the problem over and overeach day, week, month, school year. We will discuss three situations (out of many) that we have used automation to solve our problems for us.

  5. Automate Everyday Functions Security Cameras on the Blink Problem: We have a bank of security cameras that are deployed throughout our 4 campuses. These cameras have web interfaces and we have a back office server recording the video. These cameras were purchased from the lowest bidder…. They are not necessarily name brand. (They actually have no name at all) Many of the cameras will just stop responding – they have power, but are locked up.

  6. Automate Everyday Functions Security Cameras on the Blink Solution: Part 1 : We purchased a network attached power unit. These units have an IP address, web interface and control two different power outlets. The unit cost about $35 each. We plugged in two cameras POE supplies to each of these units. We can reboot the power to these cameras any time. Part 2 : We wrote a script to PING each camera. If we do not get a response from the ping, we send a signal to the power unit to reboot that camera’s port. Part 3 : We scheduled the script to run every two hours.

  7. Automate Everyday Functions Security Cameras on the Blink How we did it: Using VB Script, we do the following logic: • Read a list of camera IP addresses and corresponding power units • Ping each camera • Look for a response • If no response, send reboot command to power unit • Loop through entire list How we did it: SET objFSO = CreateObject("Scripting.FileSystemObject") SET objInputfile = objFSO.OpenTextFile("powerMan.txt") SET objOutputfile = objFSO.CreateTextFile("log.txt", True)

  8. Automate Everyday Functions Security Cameras on the Blink PowerMan.txt file: 10.10.2.221 10.10.2.215 2 Hs 100 Hall East Entrance 10.10.2.222 10.10.2.216 2 Hs 100 Hall West Entrance 10.10.2.225 10.10.2.215 1 Hs 300 Hall East Entrance 10.10.2.224 10.10.2.217 1 Hs 300 Hall East View 10.10.2.223 10.10.2.217 1 Hs 300 Hall West Entrance 10.10.2.233 10.10.2.215 1 HS 300 Hall West View 1 Camera IP Power Unit Port Description

  9. Automate Everyday Functions Security Cameras on the Blink DO WHILE NOT objInputfile.AtEndOfStream strBuff = objInputfile.readline strBuffArr = split(strBuff, " ") strCamera= strBuffArr(0) strCamName = " " SET objShell = CreateObject("WScript.Shell") SET objExec = objShell.Exec("ping " & strComputer) strPingResults = UCase(objExec.StdOut.ReadAll) Read through the file one line at time Assign this line to a variable Make an array of the stuff in the line Make a variable with the IP address Create an empty variable Opens a command object (DOS shell) Sends out a ping Gets the results of the ping

  10. Automate Everyday Functions Security Cameras on the Blink IF InStr(strPingResults, "TTL") THEN objOutputfile.writelinestrComputer & " PING = YES " ELSE for i = 3 to ubound(strBuffArr) strCamName= strCamName & " " & strBuffArr(i) next objOutputfile.writelinestrComputer & " PING = NO" objOutputfile.writeline"Attemping reboot of " & strCamName & "(" & strCamera& ")" checkPowerMan(strCamera) END IF LOOP Check the results for TTL and write to the log If no TTL (ELSE) Get the name of the camera Write to the log – twice Execute function “checkPowerMan”

  11. Automate Everyday Functions Security Cameras on the Blink Function checkPowerMan(IP) SET objPowerFile = objFSO.OpenTextFile("powerMan.txt") DO WHILE NOT objPowerFile.AtEndOfStream buff = objPowerFile.readLine buffArr= split(buff, " ") cam = buffArr(0) if cam = IP then if buffArr(1) <> "x" then PowerMan= buffArr(1) port = buffArr(2) objOutputfile.writeline"Rebooting " & IP & " on PowerMan Unit " & PowerMan & " port " & port RebootCameraPowerMan, port else objOutputfile.writeline "Camera is not connected to Power Management." end if end if LOOP objPowerFile.close End Function

  12. Automate Everyday Functions Security Cameras on the Blink Function rebootCamera Uses specific code for that power unit. That code example is available in the download files. Scheduling We placed this script on a windows server and scheduled it to run every two hours with the task scheduler.

  13. Automate Everyday Functions What is VBScript? • VBScript is a scripting language. • VBScript is based in part on Microsoft's programming language Visual Basic • While it doesn't offer the same functionality of Visual Basic, it does provide a powerful tool What is VBScript used for? • VBScript is used to give functionality and interaction to web pages. • VBScript can be used for client-side scripting. • Available on Windows OS – Client and Server and Web • Repetitive tasks

  14. Automate Everyday Functions What is VBScript? • Microsoft Visual Basic Scripting Edition brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet Information Service • If you already know Visual Basic or Visual Basic for Applications (VBA), VBScript will be very familiar. The basic concepts of VBScript are common to most programming languages. • VBScript talks to host applications using Windows Script. With Windows Script, browsers and other host applications do not require special integration code for each scripting component. Windows Script enables a host to compile scripts, obtain and call entry points, and manage the namespace available to the developer. With Windows Script, language vendors can create standard language run times for scripting. Microsoft will provide run-time support for VBScript. Microsoft is working with various Internet groups to define the Windows Script standard so that scripting engines can be interchangeable. Windows Script is used in Microsoft Internet Explorer and in Microsoft Internet Information Service. • As a developer, you can license VBScript source implementation at no charge for use in your products. Microsoft provides binary implementations of VBScript for the 32-bit Windows API, the 16-bit Windows API, and the Macintosh. VBScript is integrated with World Wide Web browsers. VBScript and Windows Script can also be used as a general scripting language in other applications.

  15. Automate Everyday Functions Server Status updates Problem : We are running an older version of Microsoft Exchange and from time to time, the information store will go off-line. When that happens, we need to restart the system store. Many times, this will take place at night or when we have no one on site. Solution: Write a script that will check the status of all running services and send a text / email message via gmail account as to the status of the exchange information store .

  16. Automate Everyday Functions Server Status updates • Set Up a list (array) of all exchange servers • Get a list of running services by display name • Get a complete list of services that you wanted

  17. Automate Everyday Functions Server Status updates Check the status of the service and send an email

  18. Automate Everyday Functions Server Status updates - outgoing email configuration

  19. Automate Everyday Functions Server Status updates Conclusion – checking the status of services on a remote machine and sending emails automatically can be accomplished via scripting. This can allow for checks on many different critical systems on your network.

  20. Automate Everyday Functions Remote Connection Location Problem : Being able to remote in to a computer is a big advantage for an understaffed department. Using Dameware or VNC or other software can be a big help, but students and teachers tend to move around. We need a way to locate the machine a user is working on. Solution : We wrote a script and added to the Logon action in the Active Directory Group Policy management. The script logs the locations of the user every time they log on. It tracks each login by username and computer name. We then wrote a script to search these files and launch remote control software based on a computer or user name.

  21. Automate Everyday Functions Remote Connection Location To start, we needed to develop a way to track every login. We did this via the Group Policy Logon Script. - we call it “ip.bat”: These lines log current info just for our own tracking purposes These two lines create the log file entries for each user / login / computer

  22. Automate Everyday Functions Remote Connection Location The file that gets created looks like this: It is a standard CSV file with the following fields: date, time, computer name,username,sessionname,logonserver We have that going to the network share and the newest entries are at the bottom of the file.

  23. Automate Everyday Functions Remote Connection Location Next, we wrote a script that asks for a user or computer name and reads the logs giving options for close matches. Here is the opening code: We set up a variable that points to the remote control software Then we open the filesystemobject to read files Next, we ask the user for a username (or computer name)

  24. Automate Everyday Functions Remote Connection Location A dialog box asks for a username Results are displayed if more than one match is made. Both computer names and user names are returned.

  25. Automate Everyday Functions Remote Connection Location . If only 1 file matches the name typed, then we connect (function) to that computer Otherwise, we build a copy locally and search the list, if no files meet the criteria typed, display “User Not Found” Otherwise, ask which user and show a list of all that match; then connect (function) to that computer.

  26. Automate Everyday Functions Remote Connection Location Finally – we launch the remote control software and pass in the computer name or IP address. We use a function we wrote called Connect: f is the FILE that the user chose. We grab the file name without the .ext We open the file and read through it to the end. The last record is the newest one. We create an array of the fields in the record and store the 3rd field in the B variable We next create a shell to run our command then execute the run command and pass in the computer name. The program launches and attempts to connect to the computer.

  27. Automate Everyday Functions Scripting Center http://technet.microsoft.com/en-us/scriptcenter/bb410849.aspx Scripting Guy Blog http://blogs.technet.com/b/heyscriptingguy/ W3 Schools http://www.w3schools.com/Vbscript/default.asp

  28. Automate Everyday Functions Other Ideas: • A script that adds users to the active directory structure • Get export from SMS • Read through file for new students • Add new students as users to the system • Scripting to type data • We have a UNIX based SMS • Write a script that reads through a file of information and enters it into the unix system. • Repeat as many as necessary • Script to move / copy / ftp files • This can be done via the shell command • You can use the “SendKeys” option to type • Allows for specific info within the script • Setting filename based on date • User specific information to be inserted • Flexible and reliable

  29. Automate Everyday Functions Questions?

  30. Automate Everyday Functions Close: My email address: iveyr@gilmerisd.org This presentation and all files: http://w3.gilmerisd.org/tcea/dal13

More Related