我正在尝试编写 Powershell 脚本,但我是脚本新手。我已经拼凑了我找到的代码,到目前为止脚本运行。我想运行以下命令:
wsl veracrypt -tc -m=nokernelcrypto /dev/sdc1
这样做我被问到:
Enter mount directory [default]:
此时我需要输入:
/mnt/wsl/PHYSICALDRIVE1
我的问题是如何在我的脚本中传递参数/mnt/wsl/PHYSICALDRIVE1
,以便在没有我输入的情况下输入它?
<#
# .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