Skip to content

Instantly share code, notes, and snippets.

@stefanteixeira
Last active September 19, 2022 02:07
Show Gist options
  • Save stefanteixeira/914b71422caa77117d99 to your computer and use it in GitHub Desktop.
Save stefanteixeira/914b71422caa77117d99 to your computer and use it in GitHub Desktop.
PowerShell script to add permissions for the MSSQLSERVER user to a directory
New-Item -ItemType Directory -Force -Path C:\Path\To\Directory
$path = "C:\Path\To\Directory"
$Acl = (Get-Item $path).GetAccessControl('Access')
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("NT SERVICE\MSSQLSERVER", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
$Acl.SetAccessRule($Ar)
Set-Acl $path $Acl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment