Help with check write date and email send

Welcome Forums General PowerShell Q&A Help with check write date and email send

Viewing 2 reply threads
  • Author
    • #249614
      Topics: 3
      Replies: 1
      Points: 36
      Rank: Member

      I am running a script that checks if the write time of a file is the correct updated one to today’s date. Is there a way to run this on more than one file in the same script? this is what i have so far that does it for just one file:

      [/crayon] [/crayon] [/crayon] [/crayon] [/crayon] [/crayon] [/crayon] [/crayon] [/crayon] [/crayon] [/crayon] [/crayon] [/crayon] [/crayon]

      Body = $Body

      [/crayon] [/crayon]


      What i need is it to check for 3 separate files

      $Path = '\\(filelocation)'

      $Path2 = '\\(filelocation)'

      $Path3 = '\\(filelocation)'

      [/crayon] [/crayon] [/crayon]

      then verify:

      if any of the variable $File, $File2, $File3 .LastWriteTime.Date -ne $today)

      it will then send the email with the original settings.
      Could anyone help me figure out how to set that up ive tried a few things but so far i havent got it

      Thank you in advance!

      • This topic was modified 1 month, 1 week ago by KarolSweats. Reason: Spelling errors
    • #249635
      Topics: 15
      Replies: 1776
      Points: 3,218
      Helping Hand
      Rank: Community Hero

      If you look at the documentation for Get-Item, Path accepts a string array, which means that you can pass multiple paths to the command. If all the files are in the same directory, then Get-ChildItem can be used as well. To send multiple files, the body should be HTML so that you can leverage ConvertTo-HTML:

      In my example I am looking at 2 weeks old, but that can be easily modified.


    • #249644
      Topics: 8
      Replies: 568
      Points: 2,171
      Helping Hand
      Rank: Community Hero


      When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to you help making their work twice or more.

      Help with email and date check from PowerShell

      Maybe this example of processing files in a foreach loop with your script will help.

      For this example, we assume there is a file that contains a list of files we want to check.


      So we will take each line (filename) of that file with Get-Content and process each through the loop

Viewing 2 reply threads
  • You must be logged in to reply to this topic.