Equivalent of net use (to list computer's connections) in powershell?

10,611

For the mapped logical drive you can use WMI class Win32_MappedLogicalDisk :

Get-WmiObject Win32_MappedLogicalDisk

Here is another way with Win32_LogicalDisk :

PS C:\> Get-WmiObject -Query "Select * From Win32_LogicalDisk Where DriveType = 4"

DeviceID     : V:
DriveType    : 4
ProviderName : \\jpbdellf1\c$
FreeSpace    :
Size         :
VolumeName   :

Edited

You are right, you can get what you need with Win32_NetworkConnection :

PS > Get-WmiObject Win32_NetworkConnection

LocalName                     RemoteName                    ConnectionState               Status
---------                     ----------                    ---------------               ------
                              \\jpbasusf1\temp              Connected                     OK

On Seven or W2K8 be careful to call this with the same user that run the NET USE because it's a session information.

Share:
10,611
mic.sca
Author by

mic.sca

Study,analyze,learn,think,look for solutions,organize,simplify,synthesize,optimize,improve.

Updated on June 15, 2022

Comments

  • mic.sca
    mic.sca almost 2 years

    According to windows help NET USE, when used without options, lists the computer's connections.

    I'd like to find a way in powershell to get a list of the Remote entries in net use's output.

    I know that as an extreme measure I can parse the result of the "net use" command itself, but I'd rather not rely on the text output of that command.

    Can anybody help me out? thank you

    Michele

    Status       Local     Remote                    Network  
    -------------------------------------------------------------------------------  
    OK                     \\SERVER02\example          Microsoft Windows Network  
    OK                     \\SERVER02\prova            Microsoft Windows Network  
    Disconnected           \\SERVER03\test             Microsoft Windows Network  
    OK                     \\SERVER02\remoteshare      Microsoft Windows Network  
    Disconnected           \\SERVER03\remoteshare   
    
  • JPBlanc
    JPBlanc over 12 years
    I Edit my answer, I think that this time it's better.