How to create share and grant multiple permissions on Windows8 using script

606 Views Asked by At

Requirement : I want to create a script to manage share and assign multiple permissions on windows 8 machine using NET SHARE command. It doesn't support SMB modules( New-SmbShare and Set-Smbshare) as this module is not compatible with Windows 8. So I found below command to create share and set permission. Please find the below powershell script:

$ErrorActionPreference="continue" 
$csv = Import-Csv C:\Temp\Smb.csv 
foreach ($details in $csv) 
{ 
    $Name="$($details.Name)" 
    $Path="$($details.Path)" 
    $User="$($details.user)" 
    $Permission="$($details.Permission)" 
    NET SHARE $NAME=$PATH \grant:$User,$Permission 
} 

To Grant Multiple Shares:

NET SHARE NAME=PATH \grant:User:Permission \grant:User:Permission

Problem :- How to grant below multiple permissions to multiple users for one single path that is mentioned in CSV file. How to pass below CSV file in the above command. Please find the below csv file

Path, Share-Name, User, Permission
C:/Temp/April, April, ABC, Read
C:/Temp/April, April, DEF, Change
C:/Temp/April, April, GEH, Full
C:/Temp/April, April, IJK, Read
0

There are 0 best solutions below