I am calling one of my scripts from a network path. Script basically only calls another program and passes to it the current directory as an argument.
When I pass $PWD as an argument, the path that my program sees is “Microsoft.PowerShell.Core\FileSystem::\my_server\public”, and it of course fails because it expects standard UNC path.
My ad hoc solution was to simply do .Replace("Microsoft.PowerShell.Core\FileSystem::", "") and it worked, but I wonder what is the real way to convert path from this “powershell” format to the standard UNC.
Is there a better solution?
Use
$pwd.ProviderPathinstead.Besides, there is a
-replaceoperator, you don’t necessarily need that method call.