So, let’s continue blogging about my PowerShell tools. I’m browsing throughout my corporate network using PowerShell mostly. The biggest problem with this approach is that when you go to the network share (by UNC path) you can’t step on \\server_name without a particular share. For example, you can set location to \\my_server\my_share, but you can’t to \\my_server. To find shares what I used to do was:
- open Explorer
- copy required share name
- copy share name
- go to terminal
- paste my share name
As you can see it’s a bit annoying. I struggled a lot with that and tried to find out a native workaround, but with no success. Finally, I made coffee, sat in front of my laptop and started thinking how Explorer acquires network shares, it’s impossible if it uses some internal APIs to which you don’t have access. net view. Of course!! Oh my god! The answer was right under my nose. Therefore, I wrote the simplest script. It’s not a sophisticated solution, but it works! Next script is quite a useful shortcut to acquire server shares through net view.
When you sourced this script, to get shares run the following code: