{"id":205,"date":"2013-03-06T09:16:40","date_gmt":"2013-03-06T14:16:40","guid":{"rendered":"https:\/\/jeremystein.com\/brain\/?p=205"},"modified":"2013-03-06T09:16:40","modified_gmt":"2013-03-06T14:16:40","slug":"powershell-script-to-archive-old-files","status":"publish","type":"post","link":"https:\/\/jeremystein.com\/brain\/powershell-script-to-archive-old-files\/","title":{"rendered":"PowerShell script to archive old files"},"content":{"rendered":"<p>On our development server, I have all emails redirected to the file system.  That directory fills up quickly, so I have a scheduled task that runs the following PowerShell hourly:<\/p>\n<p><code>Get-ChildItem C:\\MyPath -Filter \"*.eml\" | ?{$_.psIsContainer -eq $false -and $_.LastWriteTime -lt (Get-Date).AddHours(-4)} | Move-Item -Destination D:\\MyPath\\Archive<\/code><\/p>\n<p>This moves any email files (*.eml) more than four hours old to the Archive directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On our development server, I have all emails redirected to the file system. That directory fills up quickly, so I have a scheduled task that runs the following PowerShell hourly: Get-ChildItem C:\\MyPath -Filter &#8220;*.eml&#8221; | ?{$_.psIsContainer -eq $false -and $_.LastWriteTime -lt (Get-Date).AddHours(-4)} | Move-Item -Destination D:\\MyPath\\Archive This moves any email files (*.eml) more than four [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44],"tags":[],"class_list":["post-205","post","type-post","status-publish","format-standard","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/comments?post=205"}],"version-history":[{"count":0,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/205\/revisions"}],"wp:attachment":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/media?parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/categories?post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/tags?post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}