In PowerShell, how can I determine if the current drive is a networked drive or not?

前端 未结 6 1131
忘掉有多难
忘掉有多难 2020-12-19 06:08

I need to know, from within Powershell, if the current drive is a mapped drive or not.

Unfortunately, Get-PSDrive is not working \"as expected\":

PS:         


        
6条回答
  •  不知归路
    2020-12-19 06:48

    An alternative way to use WMI:

    get-wmiobject Win32_LogicalDisk | ? {$_.deviceid -eq "s:"} | % {$_.providername}

    Get all network drives with:

    get-wmiobject Win32_LogicalDisk | ? {$_.drivetype -eq 4} | % {$_.providername}

提交回复
热议问题