【发布时间】:2014-04-18 14:59:04
【问题描述】:
我有一个批处理文件,要求用户输入变量行set /p asset=。我像这样调用我的powershell脚本
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%file.ps
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%'";
我想知道如何从批处理文件中向 powershell 发送变量“资产”。
这是我的 .bat 文件内容
@Echo off
cls
Color E
cls
@echo Enter asset below
set /p asset=
@echo.
@echo your asset is %asset%
@echo.
goto startusmt
:startusmt
@echo.
@echo executing psexec ...
@echo.
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%RemoteUSMT.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -file %PowerShellScriptPath% %asset%
psexec \\%asset% -u domain\username -p password cmd
goto EOF
:EOF
PAUSE
【问题讨论】:
标签: batch-file powershell