Can you guys work it out. I'm pretty sure it's just minor syntax error cause i'm noob at this... I'm always getting "Wrong file" no matter what input($name) is.
$name = "DE123456.zip"
if ($name -contains "DE")
{
Get-ChildItem C:\test\$name |
% {
$to = $_.basename.length - 2
$path = $_.basename.substring( 0, $to)
& "C:\test\7z.exe" "x" "-y" $_.fullname "-oC:\test\$path"
}
}
ELSE
{
"Wrong file"
}