在 Powershell 脚本中,如何将选项传递给命令?

问题描述

我正在尝试编写 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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)