Automate the recreation of network shares on a new fileserver

Copper Contributor
You cannot vote on your own post
0
 

I exported the shares of a MSFC running W2008r2

I plan to present the diskcopies (via storage) on my new server

I want to set to automate the process of recreating the shares as they were

The target server is windows 2012r2

 

 

I already had a reply that exporting registry keys relative to shares are no longer in the same place between a MSFC 2008r2 and windows 2012(r2)

 

 

 

$p="c:\1","c:\2"

$s= "share1","share2"

For ($i=0; $i -lt 2; $i++) {net share $s[$i] = $p[$i] /GRANT:EVERYONE`FULL}

 

error information

CategoryInfo          : NotSpecified: (The syntax of this command is::String) [], RemoteException

    + FullyQualifiedErrorId : NativeCommandError

 

Why isn't this operating

 

 

 

 

1 Reply

Does this work for you?

 

$p="c:\1","c:\2"
$s="share1","share2"
For ($i=0; $i -lt 2; $i++)
{
    $Share = $s[$i] + "=" + $p[$i]
    net share $Share /GRANT:EVERYONE,FULL
}