Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

copy-item fails

$
0
0

$grab = get-childitem "C:\Temp" -recurse | where {$_.extension -eq ".txt"} | % { Write-Host $_.FullName } 

 

 foreach ($item in $grab) {Copy-Item $item -destination "c:\Find"}

 

When I run that above script it fails with this error.

Copy-Item : Cannot bind argument to parameter 'Path' because it is null.

 

If I Remove the $grab = and the foreach line then it works fine and returns all of the .txt files I have in my c:\temp folder.   

 

What did I do wrong?

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles