The Problem
Usually we know the UNC path(like \\server\share\file_path), we need get the local physical path, so we can login to that machine, go to that path and make some change.
The Solution
We can use WMI(Windows Management Instrumentation) to get and operate on windows management information. Win32_Share represents a shared resource on a computer system running Windows.
In Powershell, we can use get-wmiobject to get WIM class and -filter to specify the share name.
So now the solution is obvious: just one command line:
get-wmiobject -class "Win32_Share" -namespace "root\cimv2" -computername "computername" -filter "name='uncpath'" | select name,path
Output:
name path
---- ----
share-name e:\users\somefolder
Reference
get-wmiobject
Win32_Share
Usually we know the UNC path(like \\server\share\file_path), we need get the local physical path, so we can login to that machine, go to that path and make some change.
The Solution
We can use WMI(Windows Management Instrumentation) to get and operate on windows management information. Win32_Share represents a shared resource on a computer system running Windows.
In Powershell, we can use get-wmiobject to get WIM class and -filter to specify the share name.
So now the solution is obvious: just one command line:
get-wmiobject -class "Win32_Share" -namespace "root\cimv2" -computername "computername" -filter "name='uncpath'" | select name,path
Output:
name path
---- ----
share-name e:\users\somefolder
get-wmiobject
Win32_Share