Powershell

How to see what network drives a remote computer is connected to using powershell

How to see what network drives a remote computer is connected to using powershell

Highlights

  • In our Powershell series for performing day to day administrative tasks we want to move on to a task that many admins may need to perform as an information gathering tool in troubleshooting, etc.
  • ย Well, by using a Powershell to empower WMI to gather the information, we can quickly and easily get the listing of network drives that the remote computer has mapped.
  • Simply run the command above from a Powershell command window, replacing the %computername% variable with the name of the computer you are wishing to gather the information for.

In our Powershell series for performing day to day administrative tasks we want to move on to a task that many admins may need to perform as an information gathering tool in troubleshooting, etc. ย That task is finding what network drives a remote computer is connected to. ย It is so not cool to have to remote into a computer and then open up “Computer” to see which network drives they are connected to. ย Despite being cumbersome and time consuming, it is just not very efficient.

As most admins already know, Powershell is the way of the future with Microsoft scripting. ย So, how can we gather this information by utilizing Powershell? ย Well, by using a Powershell to empower WMI to gather the information, we can quickly and easily get the listing of network drives that the remote computer has mapped.

Get Remote Mapped Drives

get-wmiobject win32_mappedlogicaldisk -computername %computername%

 

Simply run the command above from a Powershell command window, replacing the %computername% variable with the name of the computer you are wishing to gather the information for. ย Incidently, theย get-wmiobjectย commandlet is extremely powerful and has a myriad of other commands that we can leverage to gather information from Windows hosts on our networks. ย We will be using this commandlet more in future posts to show you other very useful scriptlets that can empower you with all kinds of useful information.
Take a look at the SYNTAX for the get-wmiobjectย command:
 
Get-WmiObject [-Class] <String> [[-Property] <String[]>] [-Amended [<SwitchParameter>]] [-AsJob
[<SwitchParameter>]] [-Authentication <AuthenticationLevel>] [-Authority <String>] [-ComputerName <String[]>] [-Credential <PSCredential>] [-DirectRead [<SwitchParameter>]] [-EnableAllPrivileges [<SwitchParameter>]] [-Filter
<String>] [-Impersonation <ImpersonationLevel>] [-Locale <String>] [-Namespace <String>] [-ThrottleLimit <Int32>] [<CommonParameters>]

Final Thoughts

The very useful output that the command gives you is theย drive letterย as well as theย servernameย andย sharename that the remote workstation is connected to.

Subscribe to VirtualizationHowto via Email ๐Ÿ””

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com and has over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, He has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family. Also, he goes through the effort of testing and troubleshooting issues, so you don't have to.

Related Articles

One Comment

  1. Can %computername% reference a device that’s not on a local network? We use MS 365, and our domain devices are distributed all over the country.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.