사용자에게 가변 행 set /p asset=
을 묻는 배치 파일이 있습니다. 임 내가 보내는 방법 궁금 배치에서 powershell로 변수 전달
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%'";
SET PowerShellScriptPath=%ThisScriptsDirectory%file.ps
SET ThisScriptsDirectory=%~dp0
처럼 내 PowerShell 스크립트를 호출 임 내 배치 파일에서 변수 '자산'PowerShell을. 당신이 매개 변수를 취하는file.ps1
이있는 경우여기
param($asset) "The asset tag is $asset"
당신은 인수로 변수에 전달할 수 있습니다, 내 .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
-file은 무엇을하고 내 명령에는 무엇이 필요합니까? – rangerr
파일이 PowerShell 스크립트를 실행합니다. '-command'에서 파일을 호출하는 대신에'-file'을 사용할 수 있습니다. – Rynant
'PowerShell -NoProfile -ExecutionPolicy Bypass -file "% PowerShellScriptPath %"% asset %'이렇게 하시겠습니까? – rangerr