Hi all,
in linux i wrote a bash script, that check the modification date a file:
changedate_letsencrypt=$(stat /opt/certbot/letsencrypt.pfx | grep Change | awk '{print $2}')
date_now=$(date "+%F")
if [ $changedate_letsencrypt == $date_now ]; then
mail -s "Tomcat_Certificate" ....... <<< 'Certificate is updated'
else
mail -s "Tomcat_Certificate" ........ <<< 'Certificate is not updated'
fi
I need to modify for windows powershell script, but i don't know how to replace awk. I read on the internet that need to use gc, but does not help me. For example
Linux
awk -F ":" '{print $1}' file.txt
PowerShell
gc file.txt | %{ $_.Split(':')[1]; }
I wrote followings:
PS C:\Users\Administrator\Desktop\test> $changedate_letsencrypt = stat C:\certbot\letsencrypt.pfx | Select-String change
PS C:\Users\Administrator\Desktop\test> $changedate_letsencrypt
Change: 2021-05-31 09:57:55.851417200 -0700
And i need only this to print and 2021-05-31 which should be compared with today's date in the form 2021-05-31
Thank you.