Get-ChildItem works in console but not in PowerGUI Editor debugger


I am trying to create a one-liner to recursively copy and flatten a folder structure. This works in the PowerShell console but in the PowerGUI Editor debugger, no files are copied.

Get-ChildItem c:\SourceFolder\* -Include *.dll,*.pdb,*.tlb,*.exe -Recurse | Copy-Item -Destination C:\TargetFolder -Force

Am I doing something wrong? Or do debuggers act differently that the console?


Well… there are some things that behave differently in a debugger; mainly certain automatic variables such as $PSCmdlet, $MyInvocation, and so on. You’re not using any of those, and I’m not sure why this wouldn’t be working. Have you tried running just the Get-ChildItem part to make sure the proper results are coming out of there? Do you get any error messages?

Hi Dave,

it appears to be related to using variables for Get-ChildItem. My code is:

$source = 'C:\Builds\bin'
$extensions = '*.dll,*.pdb,*.tlb,*.exe'
Get-ChildItem $source\* -Include $extensions -Recurse

Using this, even in the console, produces no output. Is either $source or $extensions being interpreted incorrectly (or not as I expect)?


Your $extensions variable should be an array of strings; what you currently have is a single string with a bunch of comma-separated values. Try this:

$extensions = '*.dll', '*.pdb', '*.tlb', '*.exe'

That was it. Thanks!

I’ll pay closer attention to the cmdlet help parameter types from now on.