title: PowerShell Script To Get Timestamps of Nested files (new)
body: <p>Our DBA has set backups of website databases to every 4 hours.
  The backup of each website database is created every 4 hours and it contains 4 files (with .bak) extension.
  Folder hierarchy of these backup files are as follows:</p>
  
  <p>\\folder\sub-folder(4 X Files).bak</p>
  
  <p>The problem we have is that we have to check in each "sub-folder" if the 4 (four) .bak files are created after every four 4 hours manually.</p>
  
  <p>Can somebody help with the creation of a PowerShell script that can:</p>
  
  <ul>
  <li>Generate the list of the web sites (subfolder name) in which 4 new files are not created for the latest timestamp.</li>
  <li>Email us the list.</li>
  </ul>
  
  <p>Following is the script I am using for this but it only gives part of the required stuff:</p>
  
  <pre><code>$folder = 'B:\sub-folder\Catfish_test'
  
  $Clients = Import-Csv C:\test\backups.csv
  
  $Files = Get-ChildItem $folder -Recurse -Include @("*.bak") |
           Where-Object {($_.CreationTime -gt (Get-Date).Date)} |
           select name 
  
  $Clients | ForEach-Object {
      $Client = $_
      $ClientCheck = $Files | Where-Object {$_ -like $Client}
      if (-not $ClientCheck) { 
          Write-Warning "$Client is missing!"
      } else {
          Write-Output $ClientCheck
      }
  } | Out-File C:\test\result.txt
  </code></pre>