PowerShell: Manually Create Failover Cluster SMB Shares

# Set three variables

# Generate Domain Admins label
$subdomain=(net config workstation) -match 'Workstation domain\s+\S+$' -replace '.+?(\S+)$','$1'
$domainadmins="$subdomain`\Domain Admins";

# Create directory and its parents if they do not exists
New-Item -ItemType Directory -Force -Path $sharePath;

# Set NTFS Permissions on folder
Add-NTFSAccess –Path $sharePath –Account $domainadmins –AccessRights Full -ErrorAction SilentlyContinue

# Create the share with associated share permissions
New-SmbShare -ScopeName $smbServer -Name $shareName -Path $sharePath -FullAccess $domainadmins -FolderEnumerationMode AccessBased

Leave a Reply

Your email address will not be published. Required fields are marked *