Recreate File Shares

G

Guest

I'm trying to write a script that will recreate the file shares on a file
server i rebuilt. All the sharenames, sharepaths, descriptions are in a CSV
file.

I will use the WMI to create the shares, i just need to know the best way to
parse the CSV file to create my variables to let the WMI do its thing.
Sample of CSV file below

D:\Share1,Finance,0,,Finance Share
D:\Share2,HR,0,,Human Resources Share
D:\Share3\test,ShareName,0,10,Other Share


What is the best way to parse this?
 
J

Jorge_de_Almeida_Pinto

I'm trying to write a script that will recreate the file
shares on a file
server i rebuilt. All the sharenames, sharepaths,
descriptions are in a CSV
file.

I will use the WMI to create the shares, i just need to know
the best way to
parse the CSV file to create my variables to let the WMI do
its thing.
Sample of CSV file below

D:Share1,Finance,0,,Finance Share
D:Share2,HR,0,,Human Resources Share
D:Share3test,ShareName,0,10,Other Share


What is the best way to parse this

some code example:

add another column representing the server you want to do this

server,path,sharename,0,number_of_connections,description

this way you can create it from every computer

read each line as an array and use each part in the array.. from the
server and the path construct a UNC path and work with that

Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CreateFolder(xUNCPathDir)

Set xobjWMIsvc = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\" & <SERVER> & "rootcimv2")
Set xobjShare = xobjWMIsvc.Get("Win32_Share")
xobjShare.Create <PATH TO SHARE>, <sharename>, 0, 4294967295
(=unlimited), <description>

the scripting repository from MS provides great examples
 
S

Scott

You may be able to use the same method we have here....

net share d$=c:\downloads /Cache:None /Users:1

It looks like you have some other variables. Check the documentation on
then the share command for more info.

Scott in Arizona
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top