Mount DFS SMB share in remote PS session fails

SimonHrovatin-5821 0 Reputation points
2023-05-15T11:46:40.1333333+00:00

I'm connecting with PowerShell from my computer to a remote computer (10.44.5.142) and trying to mount a DFS share there (\10.44.5.143\dfs1\share1). It doesn't work correctly - I get error "A specified logon session does not exist. It may already have been terminated".
The root cause seems to be the combination of DFS share and remote PS session, because mounting a basic non-DFS share through PS remote session works fine. Also, mounting the DFS share directly on the computer (without PsSession) works fine.
I tested on different Windows versions but it behaves the same way.

Does anyone have any solution or ideas to solve this issue?

Below are the steps that I used to reproduce the problem. I also tried capturing network packets for analysis.

  1. From my computer connect to a remote computer
$hostRemote = New-PsSession -Computername 10.44.5.142 -Credential mydomain\administrator
Enter-PsSession $hostRemote
  1. (optional) Start packet capture
pktmon filter add -t TCP
pktmon start --capture --pkt-size 3072 --file-name C:\tcpdump.etl
  1. Mount the network share (it fails with error "A specified logon session does not exist. It may already have been terminated")
New-PsDrive -PsProvider 'FileSystem' -Scope 'Global' -Persist -Name E -Root \\10.44.5.143\dfs1\share1 -Credential mydomain\administrator
  1. (optional) Stop capture and convert etl to pcap file (for viewing in wireshark)
pktmon stop
pktmon etl2pcap C:\tcpdump.etl -o C:\tcpdump.pcap
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,032 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 31,561 Reputation points
    2023-05-15T13:21:50.0733333+00:00

    User's image

    You cannot use mydomain\administrator, you have to pass a credential object.

    https://community.spiceworks.com/topic/2313119-unc-path-new-psdrive-script-with-credential-not-working

    I would also think that with DFS you would need to use the domain name and not an IP address.