create hidden shares and set share permissions
i create hidden shares and set share permssions for subfolders. came across powershell script , able create shares (not hidden) with their share name folder names.
"get-childitem | where-object { $_.psiscontainer } | foreach-object { invoke-expression -command ([string]::concat("net share ",$_,"=",(get-location).path,"\",$_," ""/grant:everyone,full"" ""/users:unlimited"""))}"
but couldn't working when tried create hidden shares adding $ @ end of ",$_," . script this.
get-childitem | where-object { $_.psiscontainer } | foreach-object { invoke-expression -command ([string]::concat("net share ",$_,"=",(get-location).path,"\",$_,$" ""/grant:everyone,full"" ""/users:unlimited"""))}
does know what's wrong in script. in advance!
this posting provided as-is no warranties/guarantees , confers no rights.
try
get-childitem|where-object{ $_.psiscontainer } |foreach-object{ invoke-expression-command([string]::concat("net share ",$_,"=",(get-location).path,"\",$_,"$ ""/grant:everyone,full"" ""/users:unlimited"""))}
Windows Server > Windows PowerShell
Comments
Post a Comment