How to copy and move files using the command line building block?
How to copy and move files using the command line building block?
In Leapwork, you may be required to use Powershell scripts to be executed in scenarios specific to user requirements.
Users can use the Command Line Block in Leapwork to run the PowerShell script which has been created for these user-specific scenario.
Whenever you want to trigger the PowerShell script from the Command Line, use the command below, which will trigger the PowerShell script -
powershell <%PowershellScriptFilePath%>
The screenshot below refers to the "Copy_Move.ps1" which is a demo PowerShell script that was created to move a file from destination A to destination B, and the same is available for download at the end of this article for your quick reference. You should edit the file to mention the required file path and names before utilizing the same in your Leapwork environment.
Note: Sometimes the user with which the Leapwork is running might not have the permissions to execute PowerShell scripts, in that case you may utilize the Run as and provide respective user's password.
For more information about how Command-Line building block works, click here.
Attachments:
For clarification, please contact our Priority Support.