powershell - 创建指向 UNC 路径的符号链接不起作用?
问题描述
我在获取符号链接以在 powershell 中工作时遇到问题,因为我无法在网络驱动器上创建文件夹。我尝试过Test-NetConnection -ComputerName crex2cloud -Port 445
得到响应,但是当我尝试使用以下命令创建符号链接时;New-Item -ItemType SymbolicLink -path $pathh -Target $target
它不起作用。
$pathh
变量是源并且$target
是我要创建的目标文件夹,尽管每次我尝试使用上述命令创建符号链接时都会出现此错误;
New-Item : Cannot find path 'T:\csync' because it does not exist.
At line:1 char:1
+ New-Item -ItemType SymbolicLink -path $pathh -Target $target
当我尝试使用 UNC 路径时,首先会有一个暂停;那么这个错误;
New-Item : Cannot find path '\\crex2cloud\csync' because it does not exist.
At line:1 char:1
+ New-Item -ItemType SymbolicLink -path $pathh -Target $target
解决方案
使用 Test-Path 而不是 Test-NetConnection
然后您也可以将其包装在 if 语句中:
if (Test-path '\\crex2cloud\csync') {Write-host "path found"}
else
{New-Item -ItemType SymbolicLink -path $pathh -Target $target}
还要仔细检查您对共享的权限。您也可以使用管理员共享。
"\\server\c$\whateverfolder"
推荐阅读
- c# - 在下一种情况下(区间包含),您的预期行为是什么?
- postgresql - Postgres - SELECT函数()和CALL函数()之间的区别?
- angular - 带前缀的测试时间输入字段
- angular - 当我在 ag-grid 中使用特定的 customCellRenderer 时,GridReady 事件不起作用
- ios - 如何旋转到只有一个视图控制器的横向
- javascript - 调用异步函数但同步返回结果
- python - 如何将 .values_counts() 用于数据框中的列表项
- angular - Angular Spring Boot 无法正确地将变量传递给端点
- karate - 空手道加特林:将 uriPatterns 列表添加到 karateProtocol()
- python - 将存在插件交换绑定到另一个交换不会产生任何消息