Good morning UiPath Community,
I am currently using an Invoke Power Shell activity that will move a directory from one a shared drive to another location (across volumes).
A couple of questions:
1- One issue that I am encountering is that if the directory exists, then the power shell script will fail. Is there a way to force overwrite the directory with the Invoke Power Shell activity? I know that it has a -Recursive -Force parameters but I can’t seem to make it work in the UiPath activity itself.
2- Is there a way to move ALL of the directories within a particular directory at the same time instead of one by one?
Did you use the following powershell command. This should overwrite
Copy-Item -Path “D:\SourceFolder” -Destination “D:\destination” -Recurse -Force
For second point, use the following commands:
$a = (Get-ChildItem -Directory -Path “D:\RPA\New folder”).FullName
Copy-Item -Path $a -Destination “D:\RPA\destination”
Replaces paths in above commands with original folder paths on which you are working. Let me know in case of any doubts.
@Surya_Narayana_Korivipadu - thank you for your reply, yes I am using the Copy-Item -Path “D:\SourceFolder” -Destination “D:\destination” -Recurse -Force command but I am having trouble adding the -Recurse -Force parameters in the InVoke Shell Command activity in UiPath.
Could you help me with the syntax of how to add it as parameters?
Your command is correct.
Always write your powershell commands/script in a text file.
Read this text file using read text file activity. Save output in string variable.
Now pass this string variable to invoke powershell activity - command parameter.
Also check the checkbox “IsScript” in the parameters section of Invoke powershell activity.
Try this. It’ll work
I get this error when running it via text file or directly typing the string into the command line.
I think there’s something wrong in the way you’re passing paths in copy-item command.
Please share your UiPath project as zip folder. I’ll check.
Ok , I managed to fix that error as “IsScript” was not clicked.
It runs now but no results at all. Please note that I have a directory that will contain more than 1 directory and I am trying to move the whole thing to another volume.
Please see attached for sample. Make sure to change the Shell script as I put dummies for Path and Destination. Also make sure to try to move the files from one volume to another (for example C to D , or shared drive to C…e.tc). Finally, will this overwrite with the -Force as well?
UiPathCommunityTest.zip (2.3 KB)
Ok. I’ll check your code tomorrow and I’ll get back.
I would like to see how you are passing folder paths in your powershell commands
Sounds good - thank you. In the meanwhile, if I find a solution, I will post it here.
I found a solution to my invoke shell activity.
So I reverted back to how I was originally was trying to make it work and I got it to work.
I set the Origin and destination string parameters and then added the Recurse and Force parameters as booleans set to True and that worked in moving ALL of the directories into the destination path.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.