Solved

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

Posted on 2011-09-14
10
2,366 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
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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 500 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now