mic*_*sca 7 windows powershell net-use
根据Windows帮助NET USE,当使用没有选项时,列出计算机的连接.
我想在powershell中找到一种方法来获取net use输出中的Remote条目列表.
我知道作为一种极端措施,我可以解析"net use"命令本身的结果,但我宁愿不依赖于该命令的文本输出.
有人可以帮帮我吗?谢谢
米歇尔
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   
Run Code Online (Sandbox Code Playgroud)
    JPB*_*anc 11
对于映射的逻辑驱动器,您可以使用WMI类Win32_MappedLogicalDisk:
Get-WmiObject Win32_MappedLogicalDisk
Run Code Online (Sandbox Code Playgroud)
以下是Win32_LogicalDisk的另一种方法 :
PS C:\> Get-WmiObject -Query "Select * From Win32_LogicalDisk Where DriveType = 4"
DeviceID     : V:
DriveType    : 4
ProviderName : \\jpbdellf1\c$
FreeSpace    :
Size         :
VolumeName   :
Run Code Online (Sandbox Code Playgroud)
编辑
你是对的,你可以通过Win32_NetworkConnection得到你需要的东西:
PS > Get-WmiObject Win32_NetworkConnection
LocalName                     RemoteName                    ConnectionState               Status
---------                     ----------                    ---------------               ------
                              \\jpbasusf1\temp              Connected                     OK
Run Code Online (Sandbox Code Playgroud)
在Seven或W2K8上,请小心使用运行NET USE的相同用户调用它,因为它是会话信息.
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           8973 次  |  
        
|   最近记录:  |