为什么无法从 powershell 远程访问共享文件?

为什么无法从 powershell 远程访问共享文件?

鉴于:

  1. 两台机器 - alice(我的电脑)和 bob(服务器)
  2. alice 上的共享文件

bob 可以访问共享文件:

PS D:\temp> echo $env:COMPUTERNAME
bob
PS D:\temp> dir \\alice\users\mkharitonov\1.txt


    Directory: \\alice\users\mkharitonov


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        3/20/2018  12:46 PM            558 1.txt


PS D:\temp> echo $env:USERNAME
mkharitonov
PS D:\temp> echo $env:USERDOMAIN
xyz
PS D:\temp>

但如果我尝试从 alice 向 bob 打开的远程 Powershell 会话中执行此操作则不行:

PS E:\utils> echo $env:COMPUTERNAME
alice
PS E:\utils> Enter-PSSession -ComputerName bob
[bob]: PS C:\Users\mkharitonov\Documents> Test-WsMan alice


wsmid           : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor   : Microsoft Corporation
ProductVersion  : OS: 0.0.0 SP: 0.0 Stack: 3.0



[bob]: PS C:\Users\mkharitonov\Documents> dir \\alice\users\mkharitonov\1.txt
dir : Access is denied
    + CategoryInfo          : PermissionDenied: (\\alice\users\mkharitonov\1.txt:String) [Get-ChildItem], UnauthorizedAccessException
    + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand

dir : Cannot find path '\\alice\users\mkharitonov\1.txt' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\alice\users\mkharitonov\1.txt:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

[bob]: PS C:\Users\mkharitonov\Documents> dir \\alice.xyz.com\users\mkharitonov\1.txt
dir : Access is denied
    + CategoryInfo          : PermissionDenied: (\\alice.xyz...tonov\1.txt:String) [Get-ChildItem], UnauthorizedAccessException
    + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand

dir : Cannot find path '\\alice.xyz.com\users\mkharitonov\1.txt' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\alice.dayf...tonov\1.txt:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

[bob]: PS C:\Users\mkharitonov\Documents> echo $env:USERNAME
mkharitonov
[bob]: PS C:\Users\mkharitonov\Documents> echo $env:USERDOMAIN
xyz
[bob]: PS C:\Users\mkharitonov\Documents>

现在,鲍勃可以联系到艾丽斯了:

[bob]: PS C:\Users\mkharitonov\Documents> ping alice

Pinging alice.xyz.com [192.168.21.61] with 32 bytes of data:
Reply from 192.168.21.61: bytes=32 time=32ms TTL=125
Reply from 192.168.21.61: bytes=32 time=33ms TTL=125
Reply from 192.168.21.61: bytes=32 time=32ms TTL=125
Reply from 192.168.21.61: bytes=32 time=32ms TTL=125

Ping statistics for 192.168.21.61:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 32ms, Maximum = 33ms, Average = 32ms
[bob]: PS C:\Users\mkharitonov\Documents> ping alice.xyz.com

Pinging alice.xyz.com [192.168.21.61] with 32 bytes of data:
Reply from 192.168.21.61: bytes=32 time=32ms TTL=125
Reply from 192.168.21.61: bytes=32 time=32ms TTL=125
Reply from 192.168.21.61: bytes=32 time=33ms TTL=125
Reply from 192.168.21.61: bytes=32 time=33ms TTL=125

Ping statistics for 192.168.21.61:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 32ms, Maximum = 33ms, Average = 32ms
[bob]: PS C:\Users\mkharitonov\Documents>

问题是什么?为什么我无法从与 bob 的远程会话中查看目录,但通过 RDP 登录到 bob 时可以正常查看?

相关内容