1

i Have the following PowerShell Script which iterates through each file in document library folders starting with name "a" of root folder.

 if((Get-PSSnapin "Microsoft.SharePoint.PowerShell") -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}

$destination = "C:\\Test\\"
$web = Get-SPWeb -Identity "http://XYZ:4444/"
$list = $web.GetList("http://XYZ:4444/migration_test/source_lib")
#$site = "http://rssplsp08:9822"


function ProcessFolder {
    param($folderUrl)
    $folder = $web.GetFolder($folderUrl)

    foreach ($file in $folder.Files) {


        }
}

function ProcessAllSubfolders($folderCollection)
{
    foreach ($folder in $folderCollection)
    {
        if ($folder.SubFolders.Count -gt 0)
        {
            ProcessAllSubfolders($folder.SubFolders)
        }

        ProcessFolder($folder.Url)
    }
}


#Download root files
#ProcessFolder($list.RootFolder.Url)
#Download files in folders

foreach($folder in $list.RootFolder.SubFolders)
{
if($folder.Name.StartsWith("a") )
{
ProcessFolder($folder.Url)

if ($folder.Subfolders.Count -gt 0)
        {
            ProcessAllSubfolders($folder.SubFolders)
        }

}

}

$web.Close()
#$site.Dispose()

I just want to set a group permission to each file inside ($file in $folder.Files) loop in a document Library. How do I achieve it?

  • Do you mean you want to assign Item Level Permissions (for a group) on each item? – Cameron Verhelst Mar 17 '14 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.