Monday 3 November 2014

Users Home Folders Displayed As My Documents Instead of Username

On server 2008 and 2012 users home folders display as "My Documents" instead of their username. Run this PowerShell script on the directory to remove the administrators permission to the desktop.ini file: -


$folders = Get-ChildItem | where-object {$_.psiscontainer};
foreach ($folder in $folders)
{
    $ErrorActionPreference = "SilentlyContinue"
    $desktopIni = Get-ChildItem $folder -Filter desktop.ini -Force
    if ($desktopIni -ne $null)
    {
         $Acl = (Get-Item $desktopIni.FullName -Force).GetAccessControl("Access")
         $Ar = New-Object system.security.accesscontrol.filesystemaccessrule `
                   ("Administrators","Read","Deny")
         $Acl.SetAccessRule($Ar)
         Set-Acl $desktopIni.FullName $Acl
    }
}

No comments:

Post a Comment