-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCreate-SMBShare.ps1
More file actions
32 lines (26 loc) · 963 Bytes
/
Create-SMBShare.ps1
File metadata and controls
32 lines (26 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Import-Module NTFSSecurity
#variables
$sharename = "share"
$cachingmode = "none"
$continuouslyavailable = $true
$encryptdata = $false
$folderenumerationmode = "AccessBased"
$path = "D:\Shares\"
$scopename = "Cluster"
$sharepath = $path+$sharename
$fullaccess = "Everyone"
#check if path exists
$PathCheck = Test-Path $sharepath
if ($PathCheck -eq $true) {
Write-Host "$sharepath exists."
}
else {
Write-Host "$sharepath does not exist"
New-Item $sharepath -type directory
}
#create share
New-SmbShare -Name $sharename -CachingMode $cachingmode -ContinuouslyAvailable $continuouslyavailable -EncryptData $encryptdata -FolderEnumerationMode $folderenumerationmode -Path $sharepath -ScopeName $scopename -FullAccess $fullaccess
#disable inheritance and add full access
Disable-NTFSAccessInheritance $sharepath -RemoveInheritedAccessRules
Add-NTFSAccess $sharepath -Account BUILTIN\Administrators -AccessRights FullControl
Get-NTFSAccess $sharepath