Announcement

Collapse
No announcement yet.

Script Help

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script Help

    Greetings!

    I am new to the community as I am a total noob to scripting. I've been assigned a task to prepare a script at work for which I have no idea to begin with so I would appreciate some guidance on the matter.

    Issue:

    We are moving to a new platform to make snapshot images of our servers. This application will generate a log file. We want to have a script that can go into the snapshot directory (keep in mind we are under AD and this will be a network drive where the log will be stored).

    - Condition 1: First it will have to validate the file date. If the date is previous to the moment the script runs it has to flag this server as a fail. If the date is the same as the moment the script runs move to condition 2.

    - Condition 2: Read the log file and look for the word success. Once the word is found flag this server as Pass.

    This has to run through all our servers. Once the script is done reviewing all the log files it needs to generate a small report such as:

    Snapshot Software Log Validation (Blah Blah)

    Server Name Status

    xxxxxxx Pass/Fail

    It has to generate an email and attached this report to the email. On the body it should include a message stating to review the report and and include something like:

    Review attached report from summary below.

    Servers Validated Pass Fail

    Amount of servers Number Number


    As I never done scripts I am reaching out and seeking some help. Been reading the community for years and I have mostly found my solutions but when it comes to scripting I am totally lost. Any help will be most appreciate it. If you need any further information I will gladly provide it.

  • #2
    Re: Script Help

    Well I think you should first choose what language. I think powershell is the better choice but others might disagree.

    Anyhow, you already cut down the script into pieces, and as such you can write functions who execute the certain pieces.

    For example:
    With the get-childitem you can find the LastWriteTime from a file.
    http://technet.microsoft.com/en-us/l.../ee176841.aspx

    with the Get-Date you can get the current Date and time
    http://technet.microsoft.com/en-us/l.../ff730960.aspx

    With both commands you can compare the dates for condition 1.

    Another example:
    With the Select-String command you can search for certain words in text files. A nice writeup about this command can be found here:
    http://blogs.technet.com/b/heyscript...formation.aspx


    An other one, which includes much more, might be of interest for you. It includes also the an email message command (send-mailmessage)
    http://www.simple-talk.com/sysadmin/...th-powershell/
    Last edited by Dumber; 20th December 2012, 12:17.
    Marcel
    Technical Consultant
    Netherlands
    http://www.phetios.com
    http://blog.nessus.nl

    MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
    "No matter how secure, there is always the human factor."

    "Enjoy life today, tomorrow may never come."
    "If you're going through hell, keep going. ~Winston Churchill"

    Comment

    Working...
    X