I'm not sure why I'm getting the following error
Copy-Item : A positional parameter cannot be found that accepts argument 'C:\Code\PS\Auths\2.jpg'.
At C:\Code\PS\auth-grab.ps1:9 char:12
C:\Code\PS\Auths\2.jpg is the correct path.
(I'm getting one of these for each of the items in the pipeline)
When I echo $rv I get the correct pathand $_ should be right. Where am I going wrong?
oops script below :
function Generate-FileName($fi)
{
$rv = "C:\Code\PS\New\"+ $fi.Name
#echo rv
}
Get-ChildItem Auths\*.* -include 1.jpg, 2.jpg |
ForEach-Object {
Copy-Item $_ -destination Generate-FileName(Get-ChildItem $_)
}
Note if i echo $rv I get the path I want
auth-grab.ps1file