0

Have some problems with setting share permissions to folder. Cant understand in which mode to set permission to a User Domain\User

  1. NET SHARE testfolder=C:\test /GRANT:Everyone,FULL set NTFS permission but not share permission to folder

  2. Using [wmiClass] "Win32-Share".create() also do the same (write NTFS permissions)

How to set Users to share with folder?

2
  • Your question is very unclear. What do you mean by "in which mode"? Why are you granting permissions to Everyone with NET SHARE if you say you want to grant permissions to Domain\User? "Using [wmiClass] "Win32-Share".create()" is also very vague. In which way are you trying to use the WMI method? (Show the command you're using and specify where/how you're invoking it)
    – Adi Inbar
    Commented Jul 13, 2013 at 21:22
  • I am using win32_Share.create() in next function: Commented Jul 14, 2013 at 12:09

1 Answer 1

0

I am using win32_Share.create() in next function:

function shareFolder { Param ($folder, $uname) $name = $folder.Name $path = $folder.Fullname

$sd = ([WMIClass] "Win32_SecurityDescriptor").CreateInstance()

$ace = ([WMIClass] "Win32_ACE").CreateInstance()
$Trustee = ([WMIClass] "Win32_Trustee").CreateInstance()
$Trustee.Name = $uname
$Trustee.Domain = $null
$ace.AccessMask = 524288
$ace.AceFlags = 3 
$ace.AceType = 0 
$ACE.Trustee = $Trustee 
$sd.DACL += $ace.psObject.baseobject 

$mc = [WmiClass]"Win32_Share"
$InParams = $mc.psbase.GetMethodParameters("create")
$InParams.Access = $sd
$InParams.Description = "Share"
$InParams.MaximumAllowed = $Null
$InParams.Name = "test"
$InParams.Password = $Null
$InParams.Path = $folder 
$InParams.Type = [uint32]0

$mc.PSBase.InvokeMethod("Create", $InParams, $Null)

}

shareFolder "C:\test" "admin"

In this case as i had understood, ntfs permissions are setting up. How to set 'share permission' on folder (read/write)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.