使用共享点中的 CAML 查询从具有特殊字符 (%) 的文件夹中检索文件

问题描述 投票:0回答:1

我在共享点中有文件夹 (ABC%ABC),我想从特定文件夹中检索所有文件。

sharepoint caml
1个回答
0
投票

您可以按照 PowerShell 运行。

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
 
Function Get-FilesFromFolder()
{
    param
    (
        [Parameter(Mandatory=$true)] [string] $SiteURL,
        [Parameter(Mandatory=$true)] [string] $FolderURL
    )
    Try {
        #Setup Credentials to connect
        $Cred = Get-Credential
        $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
     
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Cred
 
        #Get the Folder and Files
        $Folder=$Ctx.Web.GetFolderByServerRelativeUrl($FolderURL)
        $Ctx.Load($Folder)
        $Ctx.Load($Folder.Files)
        $Ctx.ExecuteQuery()
 
        #Iterate through each File in the folder
        Foreach($File in $Folder.Files)
        {
            #Get Name for each File
            Write-Host $File.Name
        }
    }
    Catch {
        write-host -f Red "Error Getting Files from Folder!" $_.Exception.Message
    }
}
    
#Set Parameter Values
$SiteURL="https://crescent.sharepoint.com/sites/marketing"
$FolderURL="/Branding/Classified/Finance Department Files"
 
#Call the function to get list items from folder
Get-FilesFromFolder -SiteURL $SiteURL -FolderURL $FolderURL
© www.soinside.com 2019 - 2024. All rights reserved.