Many commands support UNC paths, but UNC paths look strange in scripts. Look at the following code:
ps> Test-path-path \\127.0.0.1\c$
True
It returns true, proving that a UNC path exists. Then change the current path to a non-file system path and then test:
ps> CD hkcu:\
ps> test-path-path \\127.0.0.1\c$
False
The same path but now it has failed. This is because the UNC path does not contain the letter, and PS needs to allocate the current position according to the disk character. If the current path is not included in the disk path, PowerShell assumes the currently selected location. So when you change the current directory to the registry, PS will try to get the UNC path from the current registry, which is the reason for the error.
Even worse, there are some inexplicable reasons why PS may confuse you when you are using "net use" as a network map to view the driver commands.
Here's a simple workaround, when you use a UNC path in a command, consider the current UNC path location first, which will avoid this problem:
ps> test-path-path filesystem::\\127.0.0.1\c$
True
ps> cd hkcu:\ ps>
\ 127.0.0.1\c$
False
ps> test-path-path filesystem::\\127.0.0.1\c$
True
If you are concerned about the "Net use" to create trouble, please advance the "filesystem::" Do the appropriate measures. will be able to solve the problem thoroughly.
Supports all PS versions