Resonetics
asked on
PowerShell Date Check
Hi,
i am in the process of scripting the download of McAfee updates from their FTP site.
Using PowerShell, I have created a script which pulls down the updates and then distributes them to different filers on the network.
I am trying to implement date check logic as follows.
##Delete Old Definition Files from the Share location
remove-item "\\$dest\avupdates\neta\*. *" -force -recurse
Do {remove-item "\\$dest\avupdates\EPO\com monupdater " -force -recurse
c:\AVUpdateScripts\wget.ex e ftp://ftp.nai.com/commonupdater/ -P \\$dest\avupdates\EPO -c -x -nH -r -l 0
$file = get-item \\$dest\avupdates\EPO\comn monupdater \*avv.gem}
until($file.LastWriteTime -gt (Get-Date).AddDays(-2))
I use a Do Until Loop with the date check at the end. There are times where we get files with the incorrect date, such as out of date.
Thanks.
i am in the process of scripting the download of McAfee updates from their FTP site.
Using PowerShell, I have created a script which pulls down the updates and then distributes them to different filers on the network.
I am trying to implement date check logic as follows.
##Delete Old Definition Files from the Share location
remove-item "\\$dest\avupdates\neta\*.
Do {remove-item "\\$dest\avupdates\EPO\com
c:\AVUpdateScripts\wget.ex
$file = get-item \\$dest\avupdates\EPO\comn
until($file.LastWriteTime -gt (Get-Date).AddDays(-2))
I use a Do Until Loop with the date check at the end. There are times where we get files with the incorrect date, such as out of date.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes. Often when I go to retrieve the updated definition files, they come back with a last modified date of 11/01/2012.
Is happens intermittently.
Is happens intermittently.
If the files have a timestamp other than 11/01/2012, but a query for $file.lastwritetime returns 11/01/2012 - sorry, I've never heard of an issue like you describe. I can't think of any way that would happen, unless it is perhaps some temporary state that the files go through when they are being created by wget.
ASKER
Very similar to the logic I submitted, but less complicated. Thanks for the easy solution.
Can you explain further what you mean by this? It's not clear to me.