Data Not Pulling Nightly in Powershell vs Perl


I'm in the process of migrating a lot of our scripts from Perl to Powershell, and I've run into a bit of a discrepency when polling for data in an IIS log file. I've checked the scripts multiple times, and I can't for the life of me figure out why this would be happening. Attached are the scripts in question. The original Perl script was written by a previous employee, and it unfortunately has zero comments.

Basically, in the Powershell monitor, every night from 7:15PM to 11:45PM, the Powershell script returns 0 for all statistics, but the Perl script keeps returning accurate data. See charts below:



  • Figured out the problem!

    The Powershell script was comparing the IIS Log file timestamps (UTC) with the local time (UTC-5), causing the 5-hour gap between when the log file ends and the next day begins.

    I fixed it by setting a variable $currentdt = [System.DateTime]::UtcNow      and comparing it to the datetime in the log file $calc = (New-TimeSpan -Start $testdatetime -End $currentdt)