Creating Shares Remotely

by Dec 28, 2011

Let's assume you need to access another machine's file system but there is no network share available. Provided you have local administrator privileges and WMI remoting is allowed in your Firewall, here is a one-liner that adds another share remotely:

PS> ([wmiclass]'\\storage1\root\cimv2:Win32_Share').Create('c:\', 'Hidden', 0, 12, 'secret share').ReturnValue

Just replace "storage1" with the name or IP address of the system you want to access. Note that this method does not allow for separate authentication, so your current user must have local administrator privileges on the target machine.

A return value of 0 indicates success. If you receive a "2", you do not have proper permissions.

Twitter This Tip!
ReTweet this Tip!