Posted On August 29, 2019

PowerShell: Manually Create Failover Cluster SMB Shares

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Manually Create Failover Cluster SMB Shares
# Set three variables
$shareName="someShare"
$smbServer="someClusteredVServer"
$sharePath="S:\Shares\someShare"

# 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 *

Related Post

PowerShell: Error when Pause is Placed Inside Function

Error: + Function Search-ScheduledTasks{+ ~Missing closing '}' in statement block or type definition.At C:\Users\kdoan\Desktop\Notes\test.ps1:57 char:1+…

PowerShell: Benchmark Disk Speed

Contrary to previous iteration, this version returns an object with multiple properties describing statistical analysis…

PowerShell: Use EMCOPY to Mirror a Directory

# Purpose: this PowerShell snippet is to demonstrate the use of Emcopy$source="C:\Users\tester\Desktop\Clients"$destination="C:\Users\tester\Desktop\Test"#$switches="/o /secforce /s /de…