Powershell Script to monitor a file for specific string RRS feed

  • Question

  • Hi Everyone,

    I am new to powershell scripting. Currenlty I am trying to do a script which will monitor a file for a specific string for particular time and continue to next step if the strings created in the file.

    For example, I need a Powershell Script equivalent below Linux script.

    starttime=$(date +%s)
    while [ $counter -le 0 ]
    counter=`cat logs/custom.log | grep "The Agent is now enabled" | wc -l`
    sleep 5
            runningtime=$(date +%s)
            if [ $runningtime == $[$starttime+50] ]; then #if running time = start time + 30 seconds
                echo "Agent is not started within 30 Seconds timeframe. Please check logs"

    Can someone please help me.
    • Edited by devopsn Wednesday, October 31, 2018 7:31 AM
    Wednesday, October 31, 2018 7:30 AM