Check if a certain file has been updated in last X days and error if is hasn't

I need to test if a file has been updated within the last few days (it's updated monthly) and proceed if so, but error if it hasn't been updated.
I used the following to check if the file has been updated:
Get-Item c:\temp\junk.txt | Where{$_.LastWriteTime -gt (Get-Date).AddDays(-7)}
It returns the file:
But I couldn't get that to work in a If/Else statement, so I tried Test-Path:
$path = "c:\temp\junk.txt"
If(Test-Path -path $path | Where{$_.LastWriteTime -gt (Get-Date).AddDays(-7)})
"File exists"
Else
{“No file” }
Although this always returns "No File".
Any idea what I'm doing wrong??
-Al H

Hi,
Here's how I'd do something like that:
If ((Get-Item c:\temp\junk.txt).LastWriteTime -gt (Get-Date).AddDays(-7)) {
Write-Output 'Less than 7'
Else {
Write-Output 'Too old'
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing)

Similar Messages

  • How do I get Adobe Air Desktop App to notify user that a URL text file has been updated?

    How do I get an Adobe Air Desktop App to notify user that a URLRequest ".txt" file has been updated? via blinking system tray icon or something.
    New to Air and need someone to point me in the right direction. I have been searching web for hours and probably not asking the question right.
    I have a very simple Desktop App that just loads a text file from a web location into a dynamic text field at a set timer. it just repeats this action on the timer. right now every 5 minutes
    What would the actionscript be to tell the Air App to look at the date or time stamp of the ".txt" file and notify user if its new?
    Thanks

    Try to follow below steps
    Click on Finder and then hold Command + Shift + G keys on your keypad
    It will open Go to folder window, type  exactly ~/Library and click on Go
    Then open Application Support > Adobe folders
    Trash AAMUpdater and OOBE folders.
    Now click on finder and hold Command + Shift + G keys on your keypad.
    This time type /Library and click on Go.
    Make sure to remove ~ symbol.
    Then open Application Support > Adobe folders.
    Trash AAMUpdater, Adobe Application manager, OOBE folders.
    Now Click on Finder and then hold Command + Shift + U keys on your keypad.
    It will open utilities folder.
    Trash Adobe Creative Cloud and Adobe Application Manager folders
    Download and Run CC cleaner tool from below link
    http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems/_jcr_conte nt/main-pars/accordion_container_1/accordion-par/accordion-item-1/accordion-item-par/proc e dure/proc_par/step_3/step_par/download/file.res/AdobeCreativeCloudCleanerTool.zip
    Accept the license agreement and click on Adobe Application Manager
    Then click on clean up selected
    Close the window
    Download and install Creative Cloud App from below link
    Free Creative Cloud | Download Adobe Creative Cloud free trial

  • How to know if a file has been updated in iCloud after modification?

    How to know if a file has been updated in iCloud after modification?
    I work on various app including Keynote on my Mac Pro. And after modification, i close file and I wait.
    When I see no more Internet traffic. I assume that keynote has uploaded all the works I have done into iCloud.
    But when I open the same file on my iPad on the way to work. I do not see the file updated.
    I assume that I did not wait long enough.
    I wished I had a way to enforce the updated file to upload and way to get confirmation that it has been completed.
    In windows I simply push the sync button.
    But for iCloud I do not yet see anything like that.
    Please help.

    you would be better served asking this in the iCloud discussion, where users are more knowledgeable about iCloud. Replies on iOS and iCloud issues are usually unanswered here because of our lack of knowledge.

  • TS1398 My iphone 4S has been updated to the newest software and isn't detecting internet, although sometimes it connects for a few seconds and then disappears again. I have tried everything it has said on the internet about this and it still isn't working

    My iphone 4S has been updated to the newest software and isn't detecting internet, although sometimes it connects for a few seconds and then disappears again. I have tried everything it has said on the internet about this and it still isn't working.

    Ok I think it's a problem with my router. I went to my cousin's house and the Wi-Fi worked there perfectly. I was even able to download many apps. So I guess my router probably can't take in more connections. Oh well thanks anyway.

  • [ANN] RAP on e4 has been updated to RAP 3.0 and Mars

    Hi,
    I'm happy to report that RAP on e4 has been update to the latest and
    greatest upstream versions. The major improvement with RAP 3.0 is that
    we can now support shared views between perspectives since RAP 3.0 added
    support for reparenting.
    I'll write a detailed blog post in the next days but wanted to inform
    people about the big news as fast as possible.
    Tom

    I eded up having to reinstall from scratch. Thankfully, my data was still intact, so I used Carbon Copy Cloner to copy the data to an external drive.
    Once it was safely mmigrated, I did a clean install of Tiger and the 10.4.7 update. Everything works erfectly now. I migrated the data back to the mirror and all is good.
    On further investigation, I see that many users have had problems updating Tiger with ACard cards installed, hanging on boot. I guess I should have STFF!

  • My ipad automatically tried to update skype to version 4.1.1 It has been showing installing for 3 days and says waiting on the icon. It will not allow me to delete the app. When someone calls me on skype it rings but turns off as soon as I try to answer.

    My ipad automatically tried to update skype. It has been installing for 3 days and the message waiting is on the icon. I am unable to delete skype to try and re install. I have gone to the licence page but there is nowhere that I can agree the terms as it is still trying to load.

    delete the app on itunes (on PC) then download it again.

  • TS1702 Trouble with updating my apps. It says it is updating, but has been saying that for three days and I can't use the app. What do I do to cancel or update?

    Trouble updating apps already downloaded. It says it is updating, but I cannot use the app , and it has said that for three days. Also have tried downloading new apps. They appear on the iPad, but they are dark and saying downloading. How do I cancel or get them to go thru?

    Use iTune (computer) to update the apps. When completed, sync to iPad.
    http://i1224.photobucket.com/albums/ee374/Diavonex/Album%204/94f1fe0cf3c66737ba5 7a4e6b92df1a6.jpg

  • My phone has been in recovery mode all day and now it's not even showing up in iTunes. What can I do?

    It started this morning when i was syncing it to my iTunes to get some pictrues off of it for class and it said to restore it. I've done restore before so I clicked and went along. But then it didnt work at all and came up with error 14. I shut down my pc and turned it back on, plugged it in and after an hour of syncing it worked. Left, went to class and noticed that none of my music or apps were on my phone so after my class i went and plugged it back in again. Thats when everything went down hill. It said the same things about restoring and what nots so I didnt think anything of it.  Everytime I tried again it said it would fail with the error messages as 14,2003, or 3200. Now it's not even showing up in my iTunes when i plug it in. I've tried the advice on here but nothing seems to work. Does anyone have any ideas?

    Hi Eri-kun,
    Welcome to the Support Communities!  The article below will help you troubleshoot the issue you are having syncing your iPhone with iTunes:
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    If you can't update or restore your iOS device
    http://support.apple.com/kb/ht1808
    I hope this information helps ....
    - Judy

  • Trying to delete two user accounts on my mac book air, it has been deleting them for two days and I am un able to turn my computer off, what should i do?

    How do I go about either stopping a delteing user account that is in action, or How do I reboot my computer? I am stuck not sure what to do! I am in the process of deleting two user accounts but I am stuck and can't turn my computer off reboot, or reverse it. Anyone have any ideas for me?

    Press and hold the power button for a few seconds until the power shuts off, then release, wait a few more seconds, and press it again briefly to restart.

  • The wifi button is not lit up has been this way for 2 days and have the ipod for over a year and until two day ago it work just fine anyone have any answers as to how i get get it to work again

    Need help to get the wifi button to work on my ipod

    Make 3 different iCloud accounts and use ONLY for iMessage.   That will permanently fix your issue.

  • I cant get my ipod touch  to sync to my itunes since i tunes has been updated and it is makeing me really mad

    since itunes has been updated my ipod wont synce and i want my muisc on my ipod

    iTunes: Syncing media content to iOS devices and iPod
    If you  have iTunes 11 turn on the Sidebar. Go to iTunes>View and click on Show Sidebar. You can also do a Crtl+S to show the sidebar. The sidebar is where Devices appears. and Control+B to show the Menu bar

  • Have recently updated Adobe Reader and now unable to open downloaded documents - Message received is could not open 'file name.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email a

    Have recently updated Adobe Reader and now unable to open downloaded documents - Message received is could not open 'file name.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded). When I check the file it shows Zero KB downloaded but the file appears - any suggestions?

    Obviously your download was not successful.
    What is your operating system?  How exactly do you download such files?

  • HT5313 I can't get 10.7.5 to download.  Have gone through "Software Update" several times and each time error messg suggests perhaps the file has been corrupted when downloading.  Current OS=10.7.4   Thoughts?

    I can't get 10.7.5 to download.  Have gone through "Software Update" several times and each time error messg suggests perhaps the file has been corrupted when downloading.  Current OS=10.7.4   Thoughts?

    Try downloading from here. http://support.apple.com/kb/DL1583
    Message was edited by: hpr3

  • Since the cloud has been updated, I can not see my files on safari. Why?

    Why can I not use safari to open my creative cloud page? I used that browser for months and since the cloud has been updated, I can only use google chrome.

    Found it in link from https://discussions.apple.com/message/20431895#20431895,   Or press ctrl + S to get the left sidebar showing!!!

  • Exit Code: 6 -------------------------------------- Summary --------------------------------------  - 0 fatal error(s), 8 error(s), 10 warning(s)  WARNING: DW031: Payload:{6A2E619B-E4AC-433B-A648-D458CE543A96} Adobe XMP Panels CS5 3.0.0.0 has been updated

    Exit Code: 6
    -------------------------------------- Summary --------------------------------------
    - 0 fatal error(s), 8 error(s), 10 warning(s)
    WARNING: DW031: Payload:{6A2E619B-E4AC-433B-A648-D458CE543A96} Adobe XMP Panels CS5 3.0.0.0 has been updated and has been selected for repair. The patch {5C0FEBDA-5A0E-4FC8-91CB-229A4C1561E9} Adobe XMP Panels CS5_3.1_AdobeXMPPanelsAll 3.1.0.0 will be uninstalled now.
    WARNING: DW031: Payload:{3F023875-4A52-4605-9DB6-A88D4A813E8D} Camera Profiles Installer 6.0.0.0 has been updated and has been selected for repair. The patch {A189C479-C7CD-4E08-8CCF-D999B68C0C71} Camera Profiles Installer_6.3_AdobeCameraRawProfile6.0All 6.3.0.0 will be uninstalled now.
    WARNING: DW031: Payload:{37AB3C65-E02C-4DCF-B0E0-4C2E253D8FA3} Photoshop Camera Raw 6.0.0.0 has been updated and has been selected for repair. The patch {FD58D99B-9927-4226-8E00-959A4F76BD89} Photoshop Camera Raw_6.3_AdobeCameraRaw6.0All 6.3.0.0 will be uninstalled now.
    WARNING: DW031: Payload:{6A2E619B-E4AC-433B-A648-D458CE543A96} Adobe XMP Panels CS5 3.0.0.0 has been updated and has been selected for repair. The patch {5C0FEBDA-5A0E-4FC8-91CB-229A4C1561E9} Adobe XMP Panels CS5_3.1_AdobeXMPPanelsAll 3.1.0.0 will be uninstalled now.
    WARNING: DW031: Payload:{3F023875-4A52-4605-9DB6-A88D4A813E8D} Camera Profiles Installer 6.0.0.0 has been updated and has been selected for repair. The patch {A189C479-C7CD-4E08-8CCF-D999B68C0C71} Camera Profiles Installer_6.3_AdobeCameraRawProfile6.0All 6.3.0.0 will be uninstalled now.
    WARNING: DW031: Payload:{37AB3C65-E02C-4DCF-B0E0-4C2E253D8FA3} Photoshop Camera Raw 6.0.0.0 has been updated and has been selected for repair. The patch {FD58D99B-9927-4226-8E00-959A4F76BD89} Photoshop Camera Raw_6.3_AdobeCameraRaw6.0All 6.3.0.0 will be uninstalled now.
    ----------- Payload: {A189C479-C7CD-4E08-8CCF-D999B68C0C71} Camera Profiles Installer_6.3_AdobeCameraRawProfile6.0All 6.3.0.0 -----------
    ERROR: DF037: Unable to delete directory "/Applications/Adobe/AdobePatchFiles"(Seq 2092)
    ERROR: DW063: Command ARKDeleteDirectoryCommand failed.(Seq 2092)
    ERROR: DF037: Unable to delete directory "/Applications/Adobe"(Seq 2093)
    ERROR: DW063: Command ARKDeleteDirectoryCommand failed.(Seq 2093)
    ----------- Payload: {4058E728-84D8-45CE-8E2D-5F35BD6659A1} Adobe Extension Manager CS5.5 5.5.0.0 -----------
    ERROR: DF027: Unable to copy file from "/private/tmp/.tempdiraXxwHaxr/Assets1/Adobe Extension Manager/Adobe Extension Manager CS5.5.app/Contents/Resources/ro.lproj/menubar.nib/classes.nib" to "/Applications/Adobe Extension Manager CS5.5/Adobe Extension Manager CS5.5.app/Contents/Resources/ro.lproj/menubar.nib/classes.nib" Error 0(Seq 953)
    ERROR: DW063: Command ARKCopyFileCommand failed.(Seq 953)
    ----------- Payload: {54D89F03-8EED-4FF9-BCDF-3B2E11D448A6} AdobeColorCommonSetCMYK 3.1.0.0 -----------
    WARNING: DS012: LocalizeFile: Localized string not found for locale 'de_DE' try fetching for en_US(Seq 21)
    WARNING: DS012: LocalizeFile: Localized string not found for locale 'de_DE' try fetching for en_US(Seq 22)
    ----------- Payload: {45063C56-A2A2-4FD1-A56A-A964723EEE1E} AdobeColorCommonSetRGB 3.1.0.0 -----------
    WARNING: DS012: LocalizeFile: Localized string not found for locale 'de_DE' try fetching for en_US(Seq 11)
    WARNING: DS012: LocalizeFile: Localized string not found for locale 'de_DE' try fetching for en_US(Seq 12)
    ERROR: DW050: The following payload errors were found during install:
    ERROR: DW050:  - Adobe Extension Manager CS5.5: Install failed
    what can I do?
    I tried the installation two times from a CD via shared CD drive

    Hi Daniela,
    Kindly check the Adobe - Adobe Creative Suite 3 Master Collection : System requirements
    We would recommend you to copy the installer to the local machine and then try to install it.
    If you still get this message try the download installer from : Download CS3 products
    You should also check: Errors "Exit Code: 6," "Exit Code: 7" | CS5, CS5.5
    Kindly share the results once done.
    Thanks,
    Atul Saini

Maybe you are looking for

  • Activity Monitor and Network Usage??

    I'd like to get an idea of my network usage per month prior to signing up for a service plan, and I notice that the Network tab of Activity Monitor will track Data received. When or how does the number shown there get reset to zero? What would be the

  • How to create check in batch automatically after automatic payment program

    Hello SAP Experts i am getting a  issue how to create check in batch automatically after automatic payment program ( t code is f110) Thanks & Regards Narendra.G

  • Securing single point of entry doc-lit web services

    I am designing doc-lit web services with a single point of entry, but the doc can contain requests of various types, with varying levels of authorization on the 'methods' being called by the web service as a result of the passed requests. I'm looking

  • 9i Developer Suite Documentation

    The 9i Developer Suite (9.0.2) documentation does not appear to be available on OTN. Only the latest release notes and the installation guide are available, not the whole docs. Is this deliberate or an oversight? Can we get this fixed. The link I am

  • Invalid Column Index

    I have created a readonly view object using sql query. Then i used that VO as a LOV for an attribute in another ViewObject. Now when i open that lov at run time and searches record without giving any criteria, all records are found and when i select