Create a Share from a Remote Machine using Command Line or Script

I would like to know if there is a way to create a share remotely from a command prompt or script from a Windows machine to a non-Windows machine. I am trying to do this on a Netapp SAN. I can delete a share with this simple command:

net share test \\server /delete        (test is the share name)

I don't see a way to create a remote share with net share though. There may be other ways, but a lot of the Microsoft tools rely on WMI or the RPC service, which of course does not translate to Netapp. Anyone know of a way to do this?
MCSFAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steven CarnahanNetwork ManagerCommented:
I am not sure I follow. The delete that you have entered does not "delete/remove" the share on the remote system. It simply tells your system not to connect to it. The actual share will still exist on the remote system and be connected to by any device/user that has permissions at any time.

The following would create a share locally but not remotely.

Create a new local file share
NET SHARE sharename=drive:path /REMARK:"text" [/CACHE:Manual | Automatic | No ]
0
MCSFAuthor Commented:
The command I used does in fact delete the share on the remote server. I have tested it to the Netapp and to a Windows server.

Yeah, I've seen all of the syntax to create a share, but it doesn't list anything to CREATE a remote share, just to delete one. Here is all of the available syntax:

NET SHARE
sharename
          sharename=drive:path [/GRANT:user,[READ | CHANGE | FULL]]
                               [/USERS:number | /UNLIMITED]
                               [/REMARK:"text"]
                               [/CACHE:Manual | Documents| Programs | BranchCache | None]
          sharename [/USERS:number | /UNLIMITED]
                    [/REMARK:"text"]
                    [/CACHE:Manual | Documents | Programs | BranchCache | None]
          {sharename | devicename | drive:path} /DELETE
          sharename \\computername /DELETE
0
Steven CarnahanNetwork ManagerCommented:
I'm still not sure how you are able to accomplish this.  I have attempted to replicate with a share that I have created on a server:   \\server\folder using the following:

net share \\server\folder /delete

All I get back is the shared resource does not exist.

I have attempted this from both an XP Pro and a windows 2003 server with the same results If I map a drive letter to that location then I am able to delete the drive letter from my local system however the share remains available on the remote server.

Having said that I did find this site;  http://www.tech-recipes.com/rx/2981/windows_create_share_remote_pc_from_command_line/
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

MCSFAuthor Commented:
Your syntax is a little off. In your case it would be:

net share folder \\server /delete

Yeah, I have tried WMIC, but it relies on the RPC Windows service, which Netapp does not use.
0
Steven CarnahanNetwork ManagerCommented:
I tried both ways with the same result so I did some more checking:

Hey, Scripting Guy! How can I share a folder on a remote computer?

-- RS

 
Hey, RS. One of the great things about WMI is the fact that - with one or two fairly obscure exceptions - anything you can do on the local computer you can also do on a remote computer. This is the big advantage scripting has over command line tools; a number of command line tools (including tools like net share) work only on the local computer. If you want to do something remotely, a WMI script is often the only way to go.

This was taken from:  http://blogs.technet.com/b/heyscriptingguy/archive/2005/01/07/how-can-i-share-a-folder-on-a-remote-computer.aspx
0
MCSFAuthor Commented:
Nice script. Tried it out and it works great to a Windows server, but again it relies on the RPC Windows service so it fails to the Netapp. I may have to bail on this idea and just use the GUI instead....
0
DougDCommented:
If I follow correctly then you want to avoid going to console/GUI of the Netapp filer?  One remote tool I use regularly is 'plink', part of the Putty toolset.  It allows you to use your Netapp filer credentials remotely at the command line of your host, even batching commands to be run at the filer.

Sound useful?
0
MCSFAuthor Commented:
I use Putty for the Netapp command line too. The purpose of this question is to find a way for a developer to stop a share on the Netapp so that he can make changes to an application with everyone out. Then we he is done making his changes he can create the share again. Ideally he would do this with a couple scripts or commands from a command prompt. Don't necessarily want him to be live on the Netapp command line.
0
davek101Commented:
You can use either RSH or SSH commands directly to the NetApp filer to achieve this.  The NetApp commands would be:

Add / Create a Windows Share:
cifs shares -add <share name> <path>

Delete a Windows Share:
cifs shares -delete <share name>

You could create a specific account on the NetApp controller that only has the CIFS command capability to prevent the developer from running other commands.  See the useradmin command to setup the roles; group and account.

You could create some scripts to do this just providing the share name and path.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MCSFAuthor Commented:
because
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.