Powershell和网络路径

Kla*_*ark 4 powershell

我从网络路径调用我的一个脚本.脚本基本上只调用另一个程序并将当前目录作为参数传递给它.

当我传递$ PWD作为参数时,我的程序看到的路径是"Microsoft.PowerShell.Core\FileSystem ::\my_server\public",它当然会失败,因为它需要标准的UNC路径.

我的临时解决方案是简单地做,.Replace("Microsoft.PowerShell.Core\FileSystem::", "")并且它有效,但我想知道将路径从这种"powershell"格式转换为标准UNC的真正方法是什么.

有更好的解决方案吗?

Joe*_*oey 10

$pwd.ProviderPath改用.

PS Home:\> cd \\localhost\h$
PS FileSystem::\\localhost\h$> $pwd|fl -force *


Drive        :
Provider     : FileSystem
ProviderPath : \\localhost\h$
Path         : FileSystem::\\localhost\h$
Run Code Online (Sandbox Code Playgroud)

此外,还有一个-replace运算符,您不一定需要该方法调用.