Remote terminal or File System not showing mapped network drive

I would appreciate some help with getting mapped drive info remotely. I tried using the command “net use” in terminal but doesn’t show anything. The File System option in the background tooling doesn’t show anything either.

TIA!

Hi there, i wrote a tiny little script that gets the mapped drives and puts them in a custom asset field. I have just submitted it to the community library, but it’s my first time doing that and apparently it takes time to get reviewed before being published. If this would be helpful to you, i can paste the script somewhere before you’ll find it in the community library.

Hi, that would be great.
Not sure how others share something like this. Any suggestions?

I put everything in a .txt file, you can download it by clicking here

Got the file. Thank you again!

1 Like

p.s. if you don’t get the desired results, you can try to change the Run as: from System to Logged in User. I’m still playing around with the script and i get different results on different machines. The thing is, if you run the command “net use” locally on the machine, either via Powershell or CMD, it works all the time, but if you push the script via Syncro, the results are different. Still trying to figure out why…

Same results here. Locally all good but when I run “net use” command through Syncro, I get nothing. I opened a ticket with support last week but I haven’t heard back. I’ll let you know if/when I do hear back from them.

Hey @benkim,

Mapped network drives won’t work with Syncro scripting or the virtual terminal. I got an explanation from our Windows developers a while back. They’re much smarter than me, but I’ll do my best to explain.

Our service runs with elevated privileges. When scripts or commands are passed they inherit these privileges.

Windows is very specific where drives are mapped. It will associate the network drive to the user without elevated privileges. Since we use elevated privileges whenever we run scripts, we can’t interact with mapped drives.

Here is an article that better explains the issue and offers a workaround: Mapped drives are not available - Windows Client | Microsoft Docs

This is the reason as explained in the article:

When UAC is enabled, the system creates two logon sessions at user logon. Both logon sessions are linked to one another. One session represents the user during an elevated session, and the other session where you run under least user rights.

When drive mappings are created, the system creates symbolic link objects (DosDevices) that associate the drive letters to the UNC paths. These objects are specific for a logon session and are not shared between logon sessions.

Thank you for the explanation.

this explains a lot!

The only Solution that i could find is over the Registry and thanks to many many searching i have made a working solution. HAVE FUN!

# Getting User Account List
$userList = Get-CimInstance -ClassName Win32_UserAccount

# Run over each User
foreach($user in $userList){
    # Write-Output $user.SID
    # Path where the Mounted Devices are Stored
    $path = "REGISTRY::HKEY_USERS\" + $user.SID + "\Network\*"
    
    # Check if there are Mounted Folders
    if(Test-Path $path){
        # Get the Drives
        $mountedDrives = Get-ItemProperty -Path $path
        # Make it pretty
        $mountedDrives | Format-Table -AutoSize -Property PSChildName, RemotePath, Username
    }
}
1 Like