Invoke power shell issue, want to map network drive with credentials

Hello,

I try to map network drive dynamically with credentials taken from orchestrator ( Get Credential activity ) for security purposes.
I have Invoke Power shell activity in Windows project
and put this inside

$driveLetter $drivePath and $userName are String
$password is SecureString

“New-PSDrive -Name $driveLetter -PSProvider FileSystem -Root $drivePath -Credential (New-Object -TypeName System.Management.Automation.PSCredential $userName,$password) -Persist”

Error i get is : Invoke Power Shell: Cannot process argument transformation on parameter ‘Credential’. userName

looks like it works in Legacy project but not in windows project, can you provide support ?

Not a PowerShell expert, but are you missing open and close parenthesis for the PSCredential object?

 ... System.Management.Automation.PSCredential($userName,$password)) -Persist

not better, i also tried with -ArgumentList as we can see on the web.
It works in legacy project that’s an issue from UiPath side for me

Found another topic, where a PowerShell query did not work in Windows compatibility but does on Legacy: Windows Remote Connection from UiPath - Help / Activities - UiPath Community Forum - https://forum.uipath.com/.

@loginerror This on your radar?

Hello,

to help other:
I’ve created a ticket and this is a known issue by UiPath team.
Planned to be solved for the 2023.10 version of UiPath ( coming for october)

Have a nice day

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

Hi @Matt67

Would you be able to retest it with the System 23.12.0-preview activity package? It contains a new property called Execution Mode, where you should set the earlier version of PowerShell before retrying.

1 Like

Hello @loginerror ,

Thanks for asking and reopening tickets to give some advices !
I’ve enabled pre-release activities and made a try with this new 23.12.0 and I confirm,
now it works nicely ! ( Powershell 5.1 instead of 7.2.15 )

We will now go further with this approach in terms of security

Thanks !

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.