Howdy,
I’m trying to work out a script that will get the current year/month/date and it has to be in unix utc format, then I want to specify it to always be 12:00am for the start time and 11:59pm for the end time in the command I have to run which is below.
I have to schedule this powershell script as a scheduled task. Once the task completes I need to email the result on whether it ran or failed to someone. I’ve got it close I think but I can’t get the date correct and then I also tried using & ‘command as shown below’ as well as iex ‘command as shown below’, what’s the right way?
#I think the command below puts the date correctly and the time at 12:00am, but how do I statically set 11:59pm so I only do the logs for the 1 day?
$Time = get-date -format %y%m%d00000
“iex” is an alias for the invoke-expression cmd
iex “c:\Program Files (x86)\app\util>up.exe -b $Time $Time 1 1"”
$? lets us know if the previous command was successful or not
$LASTEXITCODE gives us the exit code of the last Win32 exe execution
if (!$? -OR $LASTEXITCODE -gt 0)
send-mailmessage -from “dev01@devlab.local” -to “test.user@devlab.local>” -subject “Log Upload Failure” -body “Scheduled task to upload logs on server Dev01 failed.” -priority High -dno onSuccess, onFailure -smtpServer smtp.devlab.local