fsprojects/FSharp.Management

Powershell provider - mapping network drive does not work nor produces error output

Closed this issue · 5 comments

ntr commented

I'm trying to map network drive using powershell provider by executing code in interactive:

type PS = PowerShellProvider< "Microsoft.PowerShell.Management;Microsoft.PowerShell.Core" >
PS.``New-PSDrive``(name="M", pSProvider="FileSystem", root="\\127.0.0.1\c$", persist=true)

It fails to create the drive and does not provide any information about the error.

Corresponding powershell creates network drive:

New-PSDrive –Name "M" –PSProvider FileSystem –Root "\\127.0.0.1\c$" -persist

The reason is that you have used incorrect string literal for root parameter.
Use @ symbol to convert it to verbatim string literal => @"\\127.0.0.1\c$".

Full source code:

#r "FSharp.Management.PowerShell.dll"
#r "System.Management.Automation.dll"
open FSharp.Management

type PS = PowerShellProvider< "Microsoft.PowerShell.Management;Microsoft.PowerShell.Core" >

PS.``New-PSDrive``(name="M", pSProvider="FileSystem", root= @"\\127.0.0.1\c$", persist=true)
ntr commented

Yes, that helped. But shouldn't the provider report to user what is the problem? Via returned object/exception?

@ntr you are right, we need to find a way to catch errors and show them to the user

@kcheick Would you like to improve error reporting in PowerShell type provider?

Should be fixed in v0.4.0