Hyperlink 从sharepoint批量导出文件路径

Hyperlink 从sharepoint批量导出文件路径,hyperlink,filepath,sharepoint-online,Hyperlink,Filepath,Sharepoint Online,我正在向excel文件添加200多个超链接,以便更轻松地访问sharepoint文件夹。我尝试从sharepoint文件夹批量导出文件路径,而不是手动提取每个路径。关于如何做到这一点有什么想法吗?我们可以使用PnP PowerShell来实现它 #Config Variables $SiteURL = "https://tenant.sharepoint.com/sites/lz" $ListName = "DL0906" $FolderRelativeURL= "/sites/lz/DL091

我正在向excel文件添加200多个超链接,以便更轻松地访问sharepoint文件夹。我尝试从sharepoint文件夹批量导出文件路径,而不是手动提取每个路径。关于如何做到这一点有什么想法吗?

我们可以使用PnP PowerShell来实现它

#Config Variables
$SiteURL = "https://tenant.sharepoint.com/sites/lz"
$ListName = "DL0906"
$FolderRelativeURL= "/sites/lz/DL0910/Test"
$ExportFile="C:\temp\FileUrls.csv"  
#Get Credentials to connect
$Cred = Get-Credential

Try {
    #Connect to PNP Online
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred

    #Get All Items from the Folder
    $CAMLQuery = "<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name='FileDirRef'/><Value Type='Text'>$FolderRelativeURL</Value></Eq></Where></Query></View>"
    $FolderItems = Get-PnPListItem -List $ListName -Query $CAMLQuery

    $FileCollection = @() 
    ForEach($Item in $FolderItems)
    {
        $ExportFileUrl = New-Object PSObject 
        $ExportFileUrl | Add-Member -MemberType NoteProperty -name "File URL" -value $Item["FileRef"]
        $FileCollection += $ExportFileUrl
    }   
    $FileCollection | Export-CSV $ExportFile -NoTypeInformation
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
#配置变量
$SiteURL=”https://tenant.sharepoint.com/sites/lz"
$ListName=“DL0906”
$FolderRelativeURL=“/sites/lz/DL0910/Test”
$ExportFile=“C:\temp\fileurl.csv”
#获取连接的凭据
$Cred=获取凭证
试一试{
#联机连接到PNP
连接PnPOnline-Url$SiteURL-Credentials$Cred
#从文件夹中获取所有项目
$CAMLQuery=“$FolderRelativeURL”
$FolderItems=Get PnPListItem-List$ListName-Query$CAMLQuery
$FileCollection=@()
ForEach($FolderItems中的项目)
{
$ExportFileUrl=新对象PSObject
$ExportFileUrl |添加成员-成员类型NoteProperty-名称“文件URL”-值$Item[“FileRef”]
$FileCollection+=$ExportFileUrl
}   
$FileCollection |导出CSV$ExportFile-非类型信息
}
抓住{
写入主机“错误:$($.Exception.Message)”-foregroundcolor红色
}
参考: