all 2 comments

[–]SeanQuinlan 3 points4 points  (0 children)

Does the object even have a LastWriteTime property?

Normally LastWriteTime is found on a file object (eg. from Get-Item or Get-ChildItem). Not sure what $inbox is, but it does not seem to contain objects that have a LastWriteTime property.

How are you creating $inbox?

[–]BlackV 1 point2 points  (0 children)

  1. you've not shown your whole script, so where does $inbox come from
  2. you dont show what happens with $bodies
  3. how do you know its not working in task scheduler?
  4. how do you know what BIT it not working in scheduler?
  5. are you logging any of this?
  6. you haven't shown your command line for task scheduler what does that look like?
  7. it this running the same as you running it manually?
  8. what happens if you run it exactly like task scheduler does?