title: Automate backing up everything in each folder
body: <p>I'm in need of automating a repetitive task: I have an application that has two WCF services and one IIS published website. My target is a Staging machine used by QA. Every time code changes are made, I have to deploy to a folder as below (ignore the red outlines):</p>
  
  <p><a href="https://i.stack.imgur.com/qQAPw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qQAPw.png" alt="Backup Plan"></a></p>
  
  <p>So the root folder is, say, <code>D:\Application\My Project\v2\</code></p>
  
  <p>Within this root, there are three folders:</p>
  
  <ul>
  <li><code>ServiceExternal\</code></li>
  <li><code>ServiceInternal\</code></li>
  <li><code>Web\</code></li>
  </ul>
  
  <p>Within each of these three folders, there is a folder called <code>!Releases\</code> and this folder has many folders named in this format: YYYY-MM-DD-##</p>
  
  <p>Example: I had three deployments yesterday, so I made three folders in the <code>!Releases\</code> directory (for each of three apps) as:</p>
  
  <ul>
  <li><code>!Releases\2019-10-15-01\</code></li>
  <li><code>!Releases\2019-10-15-02\</code></li>
  <li><code>!Releases\2019-10-15-03\</code></li>
  </ul>
  
  <p>Each time, I just copied the file related to the application to the respective folder before pasting in the new files/binaries/configs. This is not a good way to do things but I had to inherit this and we are a bit under governance and cannot yet go full DevOps and pipeline this process.</p>
  
  <p>I need to automate this through a PS script:</p>
  
  <ol>
  <li>Loop through all folders in root directory (There can be more folders and not just three)</li>
  <li>In each folder, call this app folder, create a new folder within <code>!Releases\</code>:
  
  <ol>
  <li>Folder to be created of today's date + today's index (2 digits)</li>
  <li>If today's date folder is found, get the index bit and +1</li>
  </ol></li>
  <li>Once folder created, copy <em>.</em> (except the <code>!Releases\</code> folder) from the app folder to this new folder</li>
  <li>That's it.</li>
  </ol>
  
  <p>Here is what I managed to do so far:</p>
  
  <pre><code>Get-ChildItem -Recurse -Directory | ForEach-Object { }
  </code></pre>
  
  <p>And that's about it. I get a dump of everything. At this stage, I need help.</p>