[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2011-09-14
10
Medium Priority
?
3,016 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:MCSF
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 26

Expert Comment

by:pony10us
ID: 36538468
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
 

Author Comment

by:MCSF
ID: 36538565
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
 
LVL 26

Expert Comment

by:pony10us
ID: 36538858
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MCSF
ID: 36538940
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
 
LVL 26

Expert Comment

by:pony10us
ID: 36539351
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
 

Author Comment

by:MCSF
ID: 36542759
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
 
LVL 1

Expert Comment

by:DougD
ID: 36546624
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
 

Author Comment

by:MCSF
ID: 36548911
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
 
LVL 1

Accepted Solution

by:
davek101 earned 1000 total points
ID: 36566943
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
 

Author Closing Comment

by:MCSF
ID: 37069723
because
0

Featured Post

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question