title: Powershell using Invoke-Command and Get-Childitem not delivering content
body: <p>I am using Powershell 4.0 on a remote computer (<em>rem_comp</em>) to access another one (<em>loc_comp</em>; Powershell 2.0 installed here) in order to get the number of files listed without folders:</p>
  
  <pre><code>$var1 = 'H:\scripts'
  Invoke-Command -Computername loc_comp -scriptblock {(Get-Childitem $var1 -recurse | Where-Object {!$_.PSIsContainer}).count}
  </code></pre>
  
  <p>However when using <code>$var1</code> inside -scriptblock, it does not deliver anything (neither any error message). </p>
  
  <p>When using </p>
  
  <pre><code>$var1 = 'H:\scripts'
  Invoke-Command -Computername loc_comp -scriptblock {(Get-Childitem $ -recurse | Where-Object {!$_.PSIsContainer}).count}
  </code></pre>
  
  <p>it works!</p>
  
  <p>Note: Changing <code>var1</code> from ' to " does not help. </p>
  
  <p>Running the command without <code>Invoke-Command</code> locally faces the same problem.</p>
  
  <p>How to fix this?</p>