I'm trying to run the following command from a powershell script.
"C:\Program Files\VeraCrypt\VeraCrypt Format-x86.exe" /create "C:\test veracrypt file.hc" /password alongpasswordisagoodpassword /hash sha512 /encryption serpent /filesystem NTFS /size 100G /dynamic /force /silent
I've tried using
& cmd.exe ""C:\Program Files\VeraCrypt\VeraCrypt Format-x86.exe" /create "C:\test veracrypt file.hc" /password alongpasswordisagoodpassword /hash sha512 /encryption serpent /filesystem NTFS /size 100G /dynamic /force /silent"
And
$command = @'
& cmd.exe ""C:\Program Files\VeraCrypt\VeraCrypt Format-x86.exe" /create "C:\test veracrypt file.hc" /password
alongpasswordisagoodpassword /hash sha512 /encryption serpent /filesystem NTFS /size 100G /dynamic /force /silent"
'@
Invoke-Expression -Command:$command
What ever i do i get the error:
cmd.exe : 'reate' is not recognized as an internal or external command,
The 'reate' is not a typo, the c from create is actually removed in the error message. I've tried to escape the create, or put in in quotes but it keeps giving me the same error.
I also tried putting the command in a bat file and calling that but that just seems to hang without doing anything even though running the bat file works as expected.
I'm new to powershell and suspect that I'm missing something obvious. What am i missing?
You should just be able to use the call operator
&
to run the command directly without using cmd:From about_operators