Friday, 3 January 2020

Powershell - Windows - share all subfolders

if you want to share all subfolders below one folder like

homedirectories\username




Share all subfolders

Get-ChildItem | Where-Object { $_.PSIsContainer } | ForEach-Object { Invoke-Expression -Command ([string]::concat("net share ",$_,"=",(Get-Location).Path$,"\",$_," ""/GRANT:Everyone,FULL"" ""/USERS:20"""))}


Share all subfolders as hidden

Get-ChildItem | Where-Object { $_.PSIsContainer } | ForEach-Object { Invoke-Expression -Command ([string]::concat("net share ",$_,"$","=",(Get-Location).Path,"\",$_," ""/GRANT:Everyone,FULL"" ""/USERS:20"""))}




No comments:

Post a Comment