{"id":4879,"date":"2020-11-09T02:17:24","date_gmt":"2020-11-09T02:17:24","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=4879"},"modified":"2022-12-02T03:21:01","modified_gmt":"2022-12-02T03:21:01","slug":"powershell-to-find-files-changed-from-a-certain-point-and-copy-and-zip","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/powershell-to-find-files-changed-from-a-certain-point-and-copy-and-zip","title":{"rendered":"Powershell to find files changed from a certain point and copy and zip"},"content":{"rendered":"<div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">#Change Date to when DR Started<br\/>$DateTime=&quot;2020-11-06 17:00:00.0000&quot;<br\/>$FromPath=&quot;\\\\file\\path&quot;<br\/>#Make sure this folder exists and is empty<br\/>$ToPath=&quot;\\\\file\\newpath&quot;<br\/><br\/>#Copy Folder Structure<br\/>Get-ChildItem -Path $FromPath -Directory -Recurse | Where { $_.LastWriteTime -ge $DateTime } | Select-Object FullName, @{N=&quot;NewPath&quot;;E={$_.FullName.Replace($FromPath, $ToPath)}} | ForEach-Object { New-Item -Path $_.NewPath -ItemType &quot;Directory&quot; }<br\/>#Copy Files<br\/>Get-ChildItem -Path $FromPath -Recurse | Where { $_.LastWriteTime -ge $DateTime } | Select-Object FullName, @{N=&quot;NewPath&quot;;E={$_.FullName.Replace($FromPath, $ToPath)}} | ForEach-Object { Copy-Item -Path $_.FullName -Destination $_.NewPath }<br\/>#zip up<br\/>Compress-Archive -Path $ToPath -DestinationPath $ToPath&quot;\\Out.zip&quot;<\/code><\/pre> <div class=\"code-embed-infos\"> <a href=\"https:\/\/github.com\/pariswells\/public-code\/blob\/master\/findchangesandcopy.ps1\" title=\"See findchangesandcopy.ps1\" target=\"_blank\" class=\"code-embed-name\">findchangesandcopy.ps1<\/a> <a href=\"https:\/\/raw.github.com\/pariswells\/public-code\/master\/findchangesandcopy.ps1\" title=\"Back to findchangesandcopy.ps1\" class=\"code-embed-raw\" target=\"_blank\">view raw<\/a> <\/div> <\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4879","post","type-post","status-publish","format-standard","hentry","category-research"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=4879"}],"version-history":[{"count":4,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4879\/revisions"}],"predecessor-version":[{"id":6467,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4879\/revisions\/6467"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=4879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=4879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=4879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}