Script to fix issues described in KB947222

Introduction

This Windows PowerShell script will modify the file permission.

Scenarios

When user redirect the Documents folders to network share, the folders name changes back to My Documents as shown in the following figure. This issue can be fixed by denying Read permission to the administrator for the Desktop.ini files on the server. But the customers need to perform steps one by one. It would be great if we have a script to automate this task.

Script

Step 1: Click Start, type powershell in the search box on the Start Menu, right-click the Windows PowerShell icon, and then click Run Windows PowerShell as administrator. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue. 

 

Step 2:  Run the script in Windows PowerShell Console (type the name of the script at the command prompt) 

 

The result as shown in the following figure:

Part of the Script as below

PowerShell
Edit|Remove
        if ($DesktopPath -ne $null) 
        { 
            try 
            { 
                $DesktopAcl = (Get-Item $DesktopPath.FullName -Force).GetAccessControl("Access") 
                 $AclSet = New-Object System.Security.Accesscontrol.Filesystemaccessrule("administrators","Read","Deny") 
                 $DesktopAcl.SetAccessRule($AclSet) 
                 Set-Acl $DesktopPath.FullName $DesktopAcl  
                $Status = "Success" 
                 
                #define a custom object 
                $ObjInfo = New-Object -TypeName PSObject 
                Add-Member -InputObject $ObjInfo -MemberType NoteProperty -Name "Path" -Value $DesktopPath.FullName 
                Add-Member -InputObject $ObjInfo -MemberType NoteProperty -Name "Permission" -Value "Read" 
                Add-Member -InputObject $ObjInfo -MemberType NoteProperty -Name "Allow/Deny" -Value Deny 
                Add-Member -InputObject $ObjInfo -MemberType NoteProperty -Name "Status" -Value $Status 
                $Objs +$ObjInfo 
            } 

Prerequisite

Windows PowerShell 2.0

Additional Resources

Editing permissions on a file or folder

Related forum threads:

http://social.technet.microsoft.com/Forums/en-US/winserverfiles/thread/3d62322e-1c87-400b-883b-5fa00c9363d4

http://int.social.technet.microsoft.com/Forums/en-US/winserverfiles/thread/f18da2ad-d157-439b-9af7-16eb6249f01c