MarketSquare / SSHLibrary

Robot Framework test library for SSH and SFTP
http://marketsquare.github.io/SSHLibrary/
Other
158 stars 139 forks source link

Unable to execute a Power-shell script (via batch script) when we use "Execute Command" of SSHLibrary from host machine. #420

Open SN185201 opened 2 years ago

SN185201 commented 2 years ago

We are trying to create a restore point on remote machine (windows). We could see the batch script is executed but not the power shell script which is indirectly called inside batch script.

So we suspect the issue can be while running a script which in turn calls another script.

Please note when we manually execute the batch script, it successfully executes powershell script as well. The issue occurs when we try to run the batch script using SSHLibrary Execute/Start command.

Host machine (robot file): Create Windows Restore Point Open Connection 129.xxx.xxx.xxx timeout=1 hour Login xxxx xxxx Execute Command D:\CreateWindowsRestorePoint.bat

Remote machine (bat file) echo Started cd "%~dp0" PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""D:\CreateWindowsRestorePoint.ps1""' -Verb RunAs}" echo Ended

Remote machine (ps1 file) Enable-ComputerRestore -Drive "C:\" REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" /V "SystemRestorePointCreationFrequency" /T REG_DWORD /D 0 /F Checkpoint-Computer -Description "Restorepoint1" Get-ComputerRestorePoint