0

well i have a little script this should execute and install one application but really in the other computer hasn't installed i'll want to install application in the other computer

the files txt have the name of the computer yours hostname, when i execute of the script i look that my computer can connect to other computer by psexec and i can watch that appears on my screen in summary "psexec v2... - execute processes remotly, copyright, sysinternals" but after the application has not installed what i can do? i have problems in the last line

& C:\pstools\psexec.exe -u $user -p $password \$destination\c$ $app

$Computers = Get-content "C:\Users\marc\Documents\computer.txt"
$destination = Get-content "C:\Users\marc\Documents\destination.txt"
$File= "c:\Documents\program.exe"    
$app="c:\program.exe /clone_wait /s /v' /qn PROGTYPE=ENTEGRA REBOOT=Supress'"
 
Foreach ($destination in $Computers) {
$Test = Test-Path -path "\\$destination\c$"

If ($Test -eq $True) {Write-Host "The path exists, the software will be installed in $destination."}
Else {(Write-Host " the path does not exist, therefore it will be created in $destination and the installation will start")}
Echo "Copying Files to C:\$destination"
Copy-Item $File "\\$destination\c$"
echo "Second part : installing the software on $destination"

& C:\pstools\psexec.exe -u $user -p $password \\$destination\c$ $app
}
  • Why using an external command as `psexec.exe` if [PowerShell has all sort of native cmdlets](https://docs.microsoft.com/powershell/scripting/learn/remoting/running-remote-commands) to do so? – iRon May 07 '22 at 06:42
  • @iRon cause I'm new to scripting and and I really don't know much about cmdlet commands, Could you explain to me how I do an installation of an .exe remotely? – Miguel Angel May 07 '22 at 07:37
  • by certain the computer has blocked the winRM for that reason i can´t utilise commands like "Invoke-Command" i saw that with those commans were more easier – Miguel Angel May 07 '22 at 07:42
  • I guess your `psexec` issue is due to spaces/quoting and acually a duplicate with [Psexec with Powershell](https://stackoverflow.com/q/49592162/1701026) and linked question. But I don't understand why some one would block winRM and leave the door open via `psexec`. Saying that, maybe as a general workaround (and example): [how winrm can be enabled using psexec from powershell](https://stackoverflow.com/a/43203048/1701026) – iRon May 07 '22 at 09:59
  • ok, i'm going to check if I can do the remote installation by activating winRM i hope this works – Miguel Angel May 08 '22 at 02:48
  • 1
    @iRon Thank you i already could do to install the software remotely with you help – Miguel Angel May 13 '22 at 14:41

0 Answers0