none
VBScript to create net share name RRS feed

  • Question

  • OK so I have a script that I need to read a file that has old Domain SAMAccountNames and new domain SAMAccountNames from a file and then use that information to do a net share for each one to create a new share name. I can do this is powershell, but not sure what to do in VBScript. So far this is what I have.

    Const filePath = "c:\users.csv"

     Set objFSO = CreateObject("Scripting.FileSystemObject")

     Set myFile = objFSO.OpenTextFile(filePath)
    fileText = myFile.ReadAll()
    myFile.Close

     

    'foreach ($User in $Users)
    '{
    '%comspec% net share $SNCORP=D:\Users\$HPB /grant:Everyone,FULL
    '}

    Not sure what is left to do. I assume that I create variables for the headers in my csv file such as $old_domainSAM and $New_domainSAM. But short of that I have no clue. Any help would be appreciated. Thanks in advance.


    Christopher

    Thursday, October 30, 2014 8:57 PM

Answers

  • When we assign network drives to users we do not set a separate share fo reach user.  We let the AD system crate a user folder under a common share.  The system will set all of the permissions for these folders automatically.  We normally do this with Group Policy as it is easiest to manage.

    The share will get set to the correct user if in AD you set the users drive to the frive you want say "H:" and the users folder to \\server\users\%username%

    AD and GP will fill in the correct user.

    We haven't done this with scrip since Windows 2000 was released.

    GP also adds all policies necessary for managing all of the user folders as needed.


    ¯\_(ツ)_/¯

    • Marked as answer by Dan81 Friday, October 31, 2014 3:20 PM
    Thursday, October 30, 2014 10:18 PM
  • Help with what?

    I'm sure you could understand why nobody wants to write code for you that does things in a way that has been made obsolete. There's no point in doing so, you see.

    The recommendation would be to update your processes to use a more modern way. Another way to say it: There's no point in fixing your old way, because it's been fixed already by being replaced with a better way.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Dan81 Friday, October 31, 2014 3:20 PM
    Friday, October 31, 2014 3:12 PM
    Moderator

All replies

  • When we assign network drives to users we do not set a separate share fo reach user.  We let the AD system crate a user folder under a common share.  The system will set all of the permissions for these folders automatically.  We normally do this with Group Policy as it is easiest to manage.

    The share will get set to the correct user if in AD you set the users drive to the frive you want say "H:" and the users folder to \\server\users\%username%

    AD and GP will fill in the correct user.

    We haven't done this with scrip since Windows 2000 was released.

    GP also adds all policies necessary for managing all of the user folders as needed.


    ¯\_(ツ)_/¯

    • Marked as answer by Dan81 Friday, October 31, 2014 3:20 PM
    Thursday, October 30, 2014 10:18 PM
  • Yes I am aware of doing it via GP, but unfortunately I dont have that luxuary in this situation. Currently trying to allow for coexistence while we transition to the new domain. 

    Christopher

    Thursday, October 30, 2014 11:16 PM
  • Yes I am aware of doing it via GP, but unfortunately I dont have that luxuary in this situation. Currently trying to allow for coexistence while we transition to the new domain. 

    Christopher

    there is still no point in what you ask.

    There is also no need for a share per user unless you are still on NT 4 which I doubt.


    ¯\_(ツ)_/¯

    Friday, October 31, 2014 12:10 AM
  • Understood. Using Windows Server 2008 R2. Currently we use a login script that maps their H drive using their share name. For example ccarter$ is D:\Users\ccarter. Just need to add a second share name for the script to still work now that we have dual ACL the server with the home folders. Again I understand there is no point to all this, but it is currently the way my company is doing things. Any help with this would be appreciated.  

    Christopher


    • Edited by Dan81 Friday, October 31, 2014 2:42 PM
    Friday, October 31, 2014 2:39 PM
  • Help with what?

    I'm sure you could understand why nobody wants to write code for you that does things in a way that has been made obsolete. There's no point in doing so, you see.

    The recommendation would be to update your processes to use a more modern way. Another way to say it: There's no point in fixing your old way, because it's been fixed already by being replaced with a better way.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Dan81 Friday, October 31, 2014 3:20 PM
    Friday, October 31, 2014 3:12 PM
    Moderator
  • OK. Apologize for even asking the question. Seems as though this has caused a bit of an uproar on this thread with you and jrv. I will go at this alone and in the future we are moving away from this old school way. Thanks for your assistance.

    Christopher

    Friday, October 31, 2014 3:19 PM
  • Understood. Using Windows Server 2008 R2. Currently we use a login script that maps their H drive using their share name. For example ccarter$ is D:\Users\ccarter. Just need to add a second share name for the script to still work now that we have dual ACL the server with the home folders. Again I understand there is no point to all this, but it is currently the way my company is doing things. Any help with this would be appreciated.  

    Christopher


    Obviously this is not the way your company is currently doing things or you would have a script that worked. It is something you are trying to do but the reasons are not clear.

    Why would you hide the user shares when you can hide a root share and simple map the user to the shared folder.  If you are putting all users at the root of the drive then you are creating a performance and management nightmare for the system.

    if you just map the user to a folder it is easy.

    NET USE H: \\server\usershares$\%username%

    THat is all you need to do.

    TO create the folder just  use MD and sset the ACL.

    The root and the share are full modify for all but the user folders are only usable by the user and the admin.

    This is how GP expects to see thjs an can be most easily created by GP.  YOu are free to use the above and do it manually. It cannot be done by a user.  It must be done by an admin.

    In your example you are not protecting anything so what is the point of any of it.

    If you just want to create a lot of folders for users just us MD with a file of names.  Use FOR /F to loop through the file.
    FOR /?

    All of this can be more easily done with PowerShell:

    Get-Content username.txt | %{New-Item -name $_ -Path c:\usershares -ItemType Directory }


    ¯\_(ツ)_/¯

    Friday, October 31, 2014 3:41 PM