I'm kind of new to Powershell, but now I need to build a script which takes a backup and encrypts it using Veracrypt. Fortunately there is a command-line syntax to do that, but for my script I'll use the Powershell's shell instead. I've managed to call CMD from within my Powershell script, but then I need to user a pre-configured variable along with the command-line command, which I previously set in Powershell. To make a sense for my request, here's how my script goes:
$Folder="e:\shares\Test"
$Size=(Get-ChildItem $Folder -Recurse | Measure-Object -Sum Length).Sum
& 'C:\Program Files\VeraCrypt\VeraCrypt Format.exe' /create e:\shares\Test\test.hc /password test /hash sha512 /encryption serpent /filesystem NTFS /size $Size
As you can see from above example, I need to make the Veracrypt command make use of the $Size
variable for the /size
flag.
That's because I assume that my backup size will change due time.
Is therea way to call my Powershell variable from CMD?