0

at the moment i install a programm to a remote machine with batch. thats already working fine. but how can i use or "convert" the batch command below in powershell using the specific command for the prgramm to install it silent on the remote machine? this is my batch code.

set /p target=hostname 
echo.
copy /z "\\server1\tool.exe" "\\%target%\C$\temp"
echo.
PsExec.exe \\%target% cmd /c "\\%target%\C$\temp\tool.exe" /verysilent
2
  • What have you tried, and how has what you've tried failed? Ideally, you should provide a minimal reproducible example of what you've tried, and include specific information on how it failed, with error messages and/or erroneous output. Stack Overflow is not a code-writing service; the best questions are those which provide useful information so that those who answer can guide you to devising your own correct answer. See How to Ask a Good Question. Commented Apr 27, 2021 at 11:40
  • The only lines you need to change are set /p to a Read-Host, and the parameter for copy. The rest should work. Commented Apr 27, 2021 at 11:49

2 Answers 2

1
$target=hostname
Copy-Item -Path "\\server1\tool.exe" -Destination "\\$target\C$\temp"
Invoke-Command -ScriptBlock \\%target%\C$\temp\tool.exe -ComputerName $target -credential (USERNAME)

for the Invoke-Command -Scriptblock is the command you want to run, -ComputerName is the computer you want to start a process on, -Credential is the username to use to run the command. You will automatically be prompted to enter your password.

Sign up to request clarification or add additional context in comments.

Comments

0

Thanky guys for your answers. i did like that

$target = Read-Host "hostname"
Copy-Item -Path "\\server1\tool.exe" -Destination "\\$target\C$\temp"
PsExec.exe \\$target -s winrm.cmd quickconfig -q
Invoke-Command -ComputerName $target -ScriptBlock {
cmd /c "C:\temp\tool.exe" /verysilent
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.