<#====================================================================

Copyright © 2015, September. Michael Pomfret

The following updates the Local file permissions.

====================================================================#>

Write-Host “”

Write-Host “=============================================================”

Write-Host “SharePoint 2013 – Updating file permissions for the local …”

Write-Host “=============================================================”

Write-Host “”

$ProgramFiles = ${env:ProgramFiles}

$CommonProgramFiles = ${env:COMMONPROGRAMFILES}

$Windir = ${env:windir}

$Systemdrive = ${env:systemdrive}

$AllUsersProfile = ${env:AllUsersProfile}

#%ProgramFiles%\Microsoft Office Servers\15.0\Bin

# Read, execute No

# This directory is the installed location of the SharePoint 2013 binaries. All the SharePoint 2013 functionality will fail if this directory is removed or altered.

$FolderPath = $Windir + “\temp”

#Get NTFS permissiongs

$Acl = Get-Acl $FolderPath

#Disable inheritance and clear permissions

$Acl.SetAccessRuleProtection($True, $False)

$Acl = (Get-Item $FolderPath).GetAccessControl(‘Access’)

$rule = New-Object System.Security.AccessControl.FileSystemAccessRule(“Local”, ‘Read’,’ContainerInherit,ObjectInherit’, ‘None’, ‘Allow’)

$Acl.SetAccessRule($rule)

Set-Acl -path $FolderPath -AclObject $Acl