title: Accessing variables outside foreach inside it in powershell
body: <p>I have a simple code sample in which i wanted to loop through directory contents :</p>
  
  <pre><code>$path = "C:\Users\BISWAJI\Desktop\Novels"
  
  $content = dir -path $path | where { $_.Mode -match "^d.*" }
  
  foreach ( $item in $content )
  {
    "Items under the folder $path\$item are :"
    dir -path "$path\$item" | select name,mode
  }
  </code></pre>
  
  <p>The trouble is the script is not able to read the variable $path inside foreach loop . Can anyone please give me any ideas? Is this normal behavior?</p>