Invoke Power Shell Windows long path prefix Bug

Windows has a path length limit of 260 characters a workaround for this is to use a \\?\ prefix. Such a prefix works when using a regular PowerShell however using it in UiPath’s Invoke Power Shell activity it doesn’t seemed to be recognized as seen below:

Regular PS:

Invoke Power Shell activity:

Is there a difference between the UiPath’s PowerShell and a regular one? From what I can see versions are the same:

Please let me know whether there’s a workaround to this bug.

Hello @MarekBruna, thanks for writing to us. While I cannot confirm technically what is the actual implementation of UiPath Powershell activity, I can suggest you a workaround that worked personally for me. Instead of using the Powershell activity directly to execute your command, I did the following:

  1. Created a powershell script using the Powershell command window and save it as .ps1 somewhere in computer.
  2. Used a read text file activity in Studio to take my script saved from computer and output it as a variable using the properties panel.
  3. Used Invoke Powershell Script activity in Studio and put the variable name assigned previously to take my script.
  4. (Optional) In order to check my result, I used a Write Line activity to check my final output (in my case, I only needed the first row, so I used [variablename].ElementAt(0).ToString)

While I am aware this is not ideal, I also raised this issue to the team who is handling this to make it more clear on usability.

I hope this solves your concern.


Also, you may take a look here for your issue with long path: Error: LibGit2Sharp.LibGit2SharpException: path too long - #5 by marian.platonov

Hello Alex, I tried your solution and it does not make a difference, however i stumbled across the reason of this issue, see an answer below.

Hello Marian, I’m aware of that workaround however I’m not allowed to make such changes to the environment where that script is supposed to run.

Nonetheless here is I believe a valid reason a particular user gave me for this issue, it seems to be caused by an incompatible .NET framework version, see quote below:

This is because of an incompatible .NET framework version. See powershell - Windows Server 2012 R2 long file paths not working? - Stack Overflow. I just confirmed this in Visual Studio .NET v4.6.1 vs v4.7.2.

In VS test project 4.6.1, I’m getting two errors “Illegal characters in path”, just like in UiPath (Studio 2021.10.5, UiPath.System.Activities 21.10.4). Once switched to 4.7.2, I’m getting a good boolean true on any valid path beginning with "\?".

As such it seems that it is UiPath itself who needs to tackle this issue.

Did you try the same approach in a Windows project?

What do you mean by WIndows project? According to the quote above that person tried it in Visual Studio project using 4.6.1 .NET version and was seeing the same behaviour that can be spotted in UiPath, this would mean that the Invoke PowerShell activity should be re-developed by UiPath using 4.7.2+ version of .NET

Did you try this behavior in a Windows-Legacy project only?

Check the same in a Windows project.

I now tried both project types, both of them end up with the same wrong output:

Windows-Legacy project:

Windows project:


What version of UiPath Studio and UiPath.System.Activities package are you using?

version: 22.4.4

Thanks, I informed our internal team about your noticed behavior.

As soon as I have some updates, I will get back to this thread.

1 Like