Keith Smith - My Blog

Automate everything!!! with less code

Wednesday, June 3, 2015 - by Keith A. Smith

I have been writing scripts (e.g. vbsscipt,BATCH,Powershell,BASH,etc) to automate various redundant tasks over the past decade. A  few years ago I discovered a software called winautomation, I never got a chance to put it through its paces....until recently. I needed to have some sql backups moved from one location to another, this had to take place on a daily basis. In the past I would have wrote a powershell script or BATCH file to handle this, then use the task scheduler to run the script at the needed time. Instead I decided to give winautomation a shot at this, I downloaded the trial version & installed it on the box I needed the tasks to run. After that I opened up the console and I noticed so many available actions sorted by category (e.g. system actions - run a application,etc conditional statements,loops) and the list goes on. I created a job then inserted a move files action, next I put in the source and destination for the transfer. In the winautomation world it looks like

I ran this job and it worked!!! which was great. Now I wanted to add a house cleaning task which was I wanted to only retain 30days of data in the destination, to this I wrote a powershell script to do this for now, {code}Get-ChildItem -Path "driveletter:\" -Recurse | Where-Object LastWriteTIme -LT (Get-Date).AddDays(-30) | Remove-Item {/code} and saved it. Now the really cool thing I saw is that it has the ability to record mouse & keystrokes via a macro recorder, I figured I would try the next phase of this with the macro recorder.  I started the macro recorder and proceeded to open powershell, then I did cd / cd folderlocation followed by .\remove30dayoldfile.ps1 finally ctrl+alt+s to stop the macro recording.  The job actions resulted in 2 line entries

With all of this in a single job now I save then run it. The result ends up being exactly what I wanted, to finish it off I added a schedule trigger so it can run at the time & date that I needed and lastly a send email notification
once the schedule trigger was complete. So far this has been working great, I will be purchasing this because it will be a huge time saver to automate certain task very easily instead of writing complex code.
  Share Post   

View Comments Comments

Leave a Comment