I have the following code which creates a shared folder
if (!(Test-Path c:\myFolder))
{
New-Item -Path 'c:\myFolder' -ItemType Directory
}
If (!(GET-WMIOBJECT Win32_Share -Filter "Name='myFolder'”))
{
$Shares.Create(“c:\myFolder”,”myFolder”,0)
}
How can i add Read/Write permission to ‘Everyone’ to the shared folder?
I prefer not to add external dll
Thanks
The Carbon module has an Install-Share function that will do what you need:
Internally,
Install-Shareis using thenet shareconsole application. I believe if you runnet share /?, you’ll get syntax on how to create a share from the command line.Disclaimer: I am the owner/maintainer of Carbon.