How to find the local path of a shared path.
My shared path is \\somemachine\shared\scripts\testing
Its local path is D:\myshares\scripts\testing
Thanks!
How to find the local path of a shared path.
My shared path is \\somemachine\shared\scripts\testing
Its local path is D:\myshares\scripts\testing
Thanks!
Using WMI, you can get a list of shares with their local path equivalents:
PS C:\> gwmi Win32_Share
Name Path Description
---- ---- -----------
ADMIN$ C:\Windows Remote Admin
C$ C:\ Default share
IPC$ Remote IPC
You would just need to match up the Name property to your share path, then replace it to get the local path on that server using the Path
property of the results:
$name = "shared"
$share = (gwmi Win32_Share | ? { $_.Name -eq $name }
$path = $share.Path + "\scripts\testing"
Note: You can also pass the -ComputerName
parameter to the gwmi
cmdlet to run the command against another computer. You may also need to pass the -Credential
parameter to supply valid credentials.
Just in case you don't have access to WMI, this can also be accomplished using the net
command:
PS C:\> net share
Share name Resource Remark
------------------------------------------------------------------------------
C$ C:\ Default share
IPC$ Remote IPC
ADMIN$ C:\Windows Remote Admin
The command completed successfully.