Find UNC path of a network drive?

后端 未结 5 2064
盖世英雄少女心
盖世英雄少女心 2020-11-30 19:03

I need to be able determine the path of the network Q drive at work for a WEBMethods project. The code that I have before is in my configuration file. I placed single charac

5条回答
  •  忘掉有多难
    2020-11-30 19:33

    $CurrentFolder = "H:\Documents"
    $Query = "Select * from Win32_NetworkConnection where LocalName = '" + $CurrentFolder.Substring( 0, 2 ) + "'"
    ( Get-WmiObject -Query $Query ).RemoteName
    

    OR

    $CurrentFolder = "H:\Documents"
    $Tst = $CurrentFolder.Substring( 0, 2 )
    ( Get-WmiObject -Query "Select * from Win32_NetworkConnection where LocalName = '$Tst'" ).RemoteName
    

提交回复
热议问题