I use
for ($i = 0; $i -le 3; $i++) {
Get-ChildItem -path $somepath|Copy-Item -Destination "c:\somefolder\$i-${$_.Name}"
}
But the destination path never translated from variables to right letters. There what I mean:
assume $i = 2 and $_.name = file.exe
"c:\somefolder\$i-${$.Name}" going to c:\somefolder\2-"
"c:\somefolder\$i-$($.Name)" going to c:\somefolder\2-"
"c:\somefolder\${$.Name}$i" going to c:\somefolder\2-"
"c:\somefolder\${$.Name}" going to c:\somefolder\2-"
but "c:\somefolder\${$_.Name}" going to c:\somefolder\file.exe"
What am I doing wrong? How can I combine two variables together