Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell call cmd.exe command like copy /b

Tags:

powershell

cmd

I saw this already Fast and simple binary concatenate files in Powershell

I'm not interested by the answer above I'm interested about what's wrong with syntax below :

when I call a cmd.exe command like copy /b:

function join-file {
   copy /b $($args[0])+$($args[1]) $($args[2])
}

I get an error Copy-Item : A positional parameter cannot be found

like image 743
user310291 Avatar asked Mar 16 '26 19:03

user310291


1 Answers

As the error alludes to, copy is actually just an alias for Copy-Item and it does not have a /b parameter. You can call cmd to use its copy command.

function join-file {
   cmd /c copy /b $($args[0])+$($args[1]) $($args[2])
}
like image 88
Doug Maurer Avatar answered Mar 18 '26 12:03

Doug Maurer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!