In Powershell script how do I pass an option to a command?

293 Views Asked by At

I am trying to write a Powershell script and I am a novice at scripting. I have pieced together code I have found and so far the script runs. I want to run the following command:

wsl veracrypt -tc -m=nokernelcrypto /dev/sdc1

Doing it I am asked:

Enter mount directory [default]:

At this point I need to enter:

/mnt/wsl/PHYSICALDRIVE1

My question is how in my script can I pass the argument /mnt/wsl/PHYSICALDRIVE1 so it is entered without my input?

<#
# .SYNOPSIS
#  A Powershell script to help mount a Veracrypt encrypted drive through Windows Sub-system for Linux.
#>

#  This checks if a mount point exists for which to mount a drive to, if not then it creates it.
##  EDIT: Change PATH to where you want to mount the drive.
$path = "\\wsl.localhost\Ubuntu\mnt\wsl\PHYSICALDRIVE1"
If(!(test-path $path))
{
      New-Item -ItemType Directory -Force -Path $path
}

#  This mounts your drive as bare without mounting any partitions. Necessary before invoking Veracrypt to mount the partition itself.
wsl --mount \\.\PHYSICALDRIVE1 --bare

#  This runs Veracrypt correctly for cross-compatibility between Powershell and WSL.
##  EDIT: Remove '-tc' if your encrypted drive is not encrypted in Truecrypt. Change your mount location from /dev/sdc1 if sdc1 is already used by something else.
wsl veracrypt -tc -m=nokernelcrypto /dev/sdc1
0

There are 0 best solutions below