ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Find Source of Windows Mapped Drives

    IT Discussion
    windows storage mapped drive network file system smb
    5
    21
    2.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      Many ways to skin a cat, but this seems to be an easy one. Need to find a list of mapped drives on a Windows machine, including the share that they are mapped from:

      Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=4" | ForEach-Object { Write-Host ("{0} {1}" -f ($_.DeviceID), ($_.ProviderName)) }
      
      M 1 Reply Last reply Reply Quote 2
      • M
        manxam @scottalanmiller
        last edited by

        @scottalanmiller - Note, this has be run under the user context and not administrator powershell. I couldn't figure out why none of my mapped drives were showing but then realized that I opened powershell as Administrator.

        Duh...

        scottalanmillerS 1 Reply Last reply Reply Quote 2
        • black3dynamiteB
          black3dynamite
          last edited by

          Seems to only work if the mapped drives are connected. Any way to show drives that are mapped but disconnected?

          scottalanmillerS 1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller @manxam
            last edited by

            @manxam said in Find Source of Windows Mapped Drives:

            @scottalanmiller - Note, this has be run under the user context and not administrator powershell. I couldn't figure out why none of my mapped drives were showing but then realized that I opened powershell as Administrator.

            Duh...

            Yeah, only mapped when the user is there. If the user isn't there, the drives aren't mapped.

            1 Reply Last reply Reply Quote 0
            • scottalanmillerS
              scottalanmiller @black3dynamite
              last edited by

              @black3dynamite said in Find Source of Windows Mapped Drives:

              Seems to only work if the mapped drives are connected. Any way to show drives that are mapped but disconnected?

              No idea where that is stored.

              1 Reply Last reply Reply Quote 0
              • gjacobseG
                gjacobse
                last edited by

                Any idea if this will work via ScreenConnect CMD?

                scottalanmillerS 1 Reply Last reply Reply Quote 0
                • scottalanmillerS
                  scottalanmiller @gjacobse
                  last edited by

                  @gjacobse said in Find Source of Windows Mapped Drives:

                  Any idea if this will work via ScreenConnect CMD?

                  Does not.

                  JaredBuschJ 1 Reply Last reply Reply Quote 0
                  • JaredBuschJ
                    JaredBusch @scottalanmiller
                    last edited by JaredBusch

                    @scottalanmiller said in Find Source of Windows Mapped Drives:

                    @gjacobse said in Find Source of Windows Mapped Drives:

                    Any idea if this will work via ScreenConnect CMD?

                    Does not.

                    does, but you won't see user data as the SC session is run under an admin account.

                    scottalanmillerS 1 Reply Last reply Reply Quote 1
                    • scottalanmillerS
                      scottalanmiller @JaredBusch
                      last edited by

                      @jaredbusch said in Find Source of Windows Mapped Drives:

                      @scottalanmiller said in Find Source of Windows Mapped Drives:

                      @gjacobse said in Find Source of Windows Mapped Drives:

                      Any idea if this will work via ScreenConnect CMD?

                      Does not.

                      does, but you won't see user data as the SC session is run under an admin account.

                      It didn't run for me at all, threw an error. Did you wrap it in something?

                      JaredBuschJ 2 Replies Last reply Reply Quote 0
                      • JaredBuschJ
                        JaredBusch @scottalanmiller
                        last edited by JaredBusch

                        @scottalanmiller said in Find Source of Windows Mapped Drives:

                        @jaredbusch said in Find Source of Windows Mapped Drives:

                        @scottalanmiller said in Find Source of Windows Mapped Drives:

                        @gjacobse said in Find Source of Windows Mapped Drives:

                        Any idea if this will work via ScreenConnect CMD?

                        Does not.

                        does, but you won't see user data as the SC session is run under an admin account.

                        It didn't run for me at all, threw an error. Did you wrap it in something?

                        0_1530889838177_3ab38ff8-8ceb-4127-9011-72ac13ae3ba2-image.png
                        0_1530889775039_526d55d9-0d0a-433b-bc94-25958e0f039e-image.png

                        1 Reply Last reply Reply Quote 1
                        • JaredBuschJ
                          JaredBusch @scottalanmiller
                          last edited by

                          @scottalanmiller Again, this does you likely no good, as the admin session likely has nothing mapped in the first place. but it does run as it should.

                          scottalanmillerS M 2 Replies Last reply Reply Quote 0
                          • scottalanmillerS
                            scottalanmiller @JaredBusch
                            last edited by

                            @jaredbusch said in Find Source of Windows Mapped Drives:

                            @scottalanmiller Again, this does you likely no good, as the admin session likely has nothing mapped in the first place. but it does run as it should.

                            I don't see where you ran this..

                            Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=4" | ForEach-Object { Write-Host ("{0} {1}" -f ($_.DeviceID), ($_.ProviderName)) }
                            
                            JaredBuschJ 1 Reply Last reply Reply Quote 0
                            • JaredBuschJ
                              JaredBusch @scottalanmiller
                              last edited by JaredBusch

                              @scottalanmiller said in Find Source of Windows Mapped Drives:

                              @jaredbusch said in Find Source of Windows Mapped Drives:

                              @scottalanmiller Again, this does you likely no good, as the admin session likely has nothing mapped in the first place. but it does run as it should.

                              I don't see where you ran this..

                              Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=4" | ForEach-Object { Write-Host ("{0} {1}" -f ($_.DeviceID), ($_.ProviderName)) }
                              

                              bottom of the second screen shot..

                              I copied it right from this thread and ran it.

                              First without the foreach and then the full command.

                              1 Reply Last reply Reply Quote 0
                              • JaredBuschJ
                                JaredBusch
                                last edited by

                                sequence:

                                • net use to show nothing mapped.
                                • net use s: \\fsldc02\software to map an S drive
                                • net use to show mapping.
                                • Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=4" with the approriate #!ps prefix for ScreenConnect
                                • Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=4" | ForEach-Object { Write-Host ("{0} {1}" -f ($_.DeviceID), ($_.ProviderName)) } with the approriate #!ps prefix.
                                scottalanmillerS 1 Reply Last reply Reply Quote 0
                                • M
                                  manxam @JaredBusch
                                  last edited by manxam

                                  @jaredbusch said in Find Source of Windows Mapped Drives:

                                  @scottalanmiller Again, this does you likely no good, as the admin session likely has nothing mapped in the first place. but it does run as it should.

                                  @JaredBusch and @scottalanmiller and this is where my original comment came in about admin account. Most RMM tools run under elevated privileges and, therefore, return no data as they're not running under the user context. One could, however, likely do a "Start-Process powershell.exe -Credential "domain\user"" before the wmic command but it gets awfully complicated at that point.

                                  JaredBuschJ 1 Reply Last reply Reply Quote 2
                                  • JaredBuschJ
                                    JaredBusch @manxam
                                    last edited by JaredBusch

                                    @manxam said in Find Source of Windows Mapped Drives:

                                    @jaredbusch said in Find Source of Windows Mapped Drives:

                                    @scottalanmiller Again, this does you likely no good, as the admin session likely has nothing mapped in the first place. but it does run as it should.

                                    @JaredBusch and @scottalanmiller and this is where my original comment came in about admin account. Most RMM tools run under elevated privileges and, therefore, return no data as they're not running under the user context. One could, however, likely do a "Start-Process powershell.exe -Credential "domain\user"" before the wmic command but it gets awfully complicated at that point.

                                    Yes, you are right, but I was just correcting the statement that it would not run from ScreenConnect.

                                    M 1 Reply Last reply Reply Quote 0
                                    • M
                                      manxam @JaredBusch
                                      last edited by manxam

                                      @jaredbusch, totally understood. I wasn't claiming otherwise. I just wanted to vocalize it for others who jump into the thread.
                                      Thanks for the verification.

                                      1 Reply Last reply Reply Quote 0
                                      • scottalanmillerS
                                        scottalanmiller @JaredBusch
                                        last edited by

                                        @jaredbusch said in Find Source of Windows Mapped Drives:

                                        • Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=4" | ForEach-Object { Write-Host ("{0} {1}" -f ($_.DeviceID), ($_.ProviderName)) } with the approriate #!ps prefix.

                                        I've not used that before. I use @powershell and that normally works but did not work here.

                                        JaredBuschJ 1 Reply Last reply Reply Quote 0
                                        • JaredBuschJ
                                          JaredBusch @scottalanmiller
                                          last edited by JaredBusch

                                          @scottalanmiller said in Find Source of Windows Mapped Drives:

                                          @jaredbusch said in Find Source of Windows Mapped Drives:

                                          • Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=4" | ForEach-Object { Write-Host ("{0} {1}" -f ($_.DeviceID), ($_.ProviderName)) } with the approriate #!ps prefix.

                                          I've not used that before. I use @powershell and that normally works but did not work here.

                                          That is the proper way to run powershell from ScreenConnect.

                                          So what you were doing was launch powershell from a command prompt session.

                                          Doing @powershell, you probably need to handle escaping quotes or something is all.

                                          scottalanmillerS 1 Reply Last reply Reply Quote 0
                                          • scottalanmillerS
                                            scottalanmiller @JaredBusch
                                            last edited by

                                            @jaredbusch said in Find Source of Windows Mapped Drives:

                                            Doing @powershell, you probably need to handle escaping quotes or something is all.

                                            Likely

                                            JaredBuschJ 1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post