Alternatively, you can use a bunch of pscp to put the scripts on the server, then plink , to execute the command on the server. But in this case, I don’t really understand the meaning of using PowerShell - it’s quite possible to get along with the banal BATCH script. Both utilities come with PuTTY .
An example of a PowerShell script using pscp and plink:
$PuTTYPath = "C:\Program Files (x86)\PuTTY" $User = 'administrator' $Pass = Read-Host 'Password' -AsSecureString | ConvertFrom-SecureString $HostName = 'ubuntu-test' # Кладём скрипт на сервер; обязательно с флагом -Wait, чтобы скрипт дождался загрузки файлов Start-Process -FilePath "$PuTTYPath\pscp.exe" ` -ArgumentList "-pw $Pass D:\Soft\Ubuntu\*.sh $User@$HostName`:/home/administrator" -Wait # Запускаем скрипты (предполагаем, что нам не важен порядок запуска) Start-Process -FilePath "$PuTTYPath\plink.exe" ` -ArgumentList "-ssh -pw $Pass $User@$HostName cd /home/administrator/ && chmod +x *.sh && ./*.sh"
bash. - aleksandr barakin