title: How to move folders from one location to another using PowerShell
body: <p>So i have a directory full of folders that i want to move to another area, also i only want to move the folders that were created 30 days ago or more. I have a script that does what i need for files but it doesnt seem to work for folders. Script is below</p>
  
  <p>Script for moving files</p>
  
  <pre><code> param (
      [Parameter(Mandatory=$true)][string]$destinationRoot
   )
  
  $path = (Get-Item -Path ".\").FullName
  
  Get-ChildItem -Recurse | ?{ $_.PSIsContainer }
  Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} |
  Foreach-Object {
      $content = $path + "\" + $_.Name
  
      $year = (Get-Item $content).LastWriteTime.year.ToString()
      $monthNumber = (Get-Item $content).LastWriteTime.month
      $month = (Get-Culture).DateTimeFormat.GetMonthName($monthNumber)
  
      $destination = $destinationRoot + "\" + $year + "\" + $month 
  
      New-Item -ItemType Directory -Force -Path $destination
  
      Move-Item -Path $content -Destination $destination -force
  
  }
  </code></pre>
  
  <p>The Get-ChildItem portion does not seem to pull directories in like it should.</p>