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)?