[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 549
  • Last Modified:

Need a script to automatically create a share

I am looking for a script that when i create a user in active directory it automatically creates a share named after the user on a specified server. Any help is appreciated
0
lenarbitman
Asked:
lenarbitman
  • 2
2 Solutions
 
sr75Commented:
You can do so using the Create method of the WMI Win32_Share class

http://msdn2.microsoft.com/en-us/library/aa394435%28VS.85%29.aspx
0
 
sr75Commented:
this is from Microsoft at this location:

http://www.microsoft.com/technet/scriptcenter/guide/sas_fil_grpq.mspx?mfr=true
Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
errReturn = objNewShare.Create _
 ("C:\Finance", "FinanceShare", FILE_SHARE, _
 MAXIMUM_CONNECTIONS, "Public share for the Finance group.")
Wscript.Echo errReturn

Open in new window

0
 
oBdACommented:
Do you still have NT4 clients?
If not, I would recommend against creating a dedicated user share for each user. It's unnecessary and only creates technical overhead on the server and administrative overhead for you.
Just map the home folder directly; since W2k, drives can be mapped to a subfolder of a share:
\\server\share\%username%
0

Featured Post

Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now