How to map network drive?

How to map network drive using credentials in windows using UiPath.

Hi @Arun_Singh

The following thread contains some information aligned with your requirement:

You can also refer this video:

Hope this helps,
Best Regards.

I have referred the same video, however I didn’t received any exception and the network drive was also not mapped.

@Arun_Singh

Please give the following a try:

  1. Use a ‘Invoke PowerShell’ activity.
  2. In the properties, set the following values:

CommandText: "New-PSDrive -Name Z -PSProvider FileSystem -Root \\server\share -Credential mydomain\myusername"
IsScript: True

  1. Use another ‘Invoke PowerShell’ activity & in the properties panel, set the following values:

CommandText: "Exit-PSSession"
IsScript: True

  1. Save and run the workflow. The network drive should be mapped with the specified credentials.

Hope this helps,
Best Regards.

1 Like

Getting this error message:

22.10.4+Branch.support-v22.10.Sha.b4be88e3b45fb05c4bcd71885c763d4f2095f959 Source: Invoke Power Shell (Throw) Message: Cannot process argument transformation on parameter ‘Credential’. A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: Enter your credentials. Exception Type: System.Management.Automation.ParameterBindingArgumentTransformationException System.Management.Automation.ParameterBindingArgumentTransformationException: Cannot process argument transformation on parameter ‘Credential’. A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: Enter your credentials. —> System.Management.Automation.Host.HostException: A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: Enter your credentials. at System.Management.Automation.Internal.Host.InternalHostUserInterface.ThrowPromptNotInteractive(String promptMessage) at System.Management.Automation.Internal.Host.InternalHostUserInterface.PromptForCredential(String caption, String message, String userName, String targetName, PSCredentialTypes allowedCredentialTypes, PSCredentialUIOptions options) at System.Management.Automation.Internal.Host.InternalHostUserInterface.PromptForCredential(String caption, String message, String userName, String targetName) at System.Management.Automation.CredentialAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData) at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags) — End of inner exception stack trace — at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

@Arun_Singh

Looks like PowerShell command being invoked requires user interaction to provide credentials, but the process is running in a non-interactive mode, so it cannot provide the credentials.

Can you try modifying your PowerShell command to accept credentials in a non-interactive mode.

Best Regards.

Hi @Arun_Singh ,

Check this below link,

Hope this helps :slight_smile:

  1. Assign UserName, Password, DriveLetter, and DrivePath to separate variables.
  2. Password must come within a single quote while assigning. eg - ‘Welsome$123’ since PowerShell will restrict the ‘$’ symbol.
  3. Invoke a power shell activity and include “net use “+ DriveLetter +”: “+ DrivePath +” /user:itape"+ UserName +” "+ Password in CommandText property.
  4. IsScript property must be checked.
  5. TypeArgument property must be a string.
1 Like

@Janet_Caroline1 Thank you. It’s working for me :+1:

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