简体   繁体   English

如何从 powershell 获取 SharePoint 中的元数据(列值)

[英]How to get metadata(Column Value) in SharePoint from powershell

I am trying to get the metadata(column values) for each file in powershell (refer image and code till now) While running the below code name i am getting, but other values if i try like only the name is priniting..我正在尝试获取 powershell 中每个文件的元数据(列值)(到目前为止,请参考图像和代码)在运行下面的代码名称时,我得到了其他值,但如果我尝试只有名称正在打印,则为其他值。

 $File.Name + $File.FieldValues.Hash | Format-Table

is there any way to get all the values from the columns for every file in the folder?有没有办法从文件夹中每个文件的列中获取所有值? - -

Code Till Now -到目前为止的代码-

 Import-Module SharePointPnPPowerShellOnline #Get Connection to the url, #Connect-PnPOnline $URL Connect-PnPOnline "Some SharePoint Url" -UseWebLogin $SharePointFolderPath = "Some folder in Shared Documents" $FolderItems = Get-PnPFolderItem -ItemType file -Recursive -FolderSiteRelativeUrl $fileURL foreach($file in $FolderItems){ #$File = Get-PnPFile -Url $fileURL -AsListItem -ErrorAction SilentlyContinue #by using this and giving the exact path/Filename.txt the values are coming for only that file but not for all the files.. but not with get folder items also. $File.Name #Only name is coming $File.Hash #Hash column is custom created by myself but its not returning anything other than null,the actual value should be returned. #$File }

ScreenShot for the metadata column元数据列的屏幕截图

Here is a link that might help.这是一个可能有帮助的链接 Below is a script I was playing with while learning about Metadata using the Get-FileMetaData function.下面是我在使用 Get-FileMetaData function 学习元数据时使用的脚本。 It's in the PowerShell Gallery and I think it is safe to run.它在 PowerShell 库中,我认为可以安全运行。

First run: Install-Module -Name PSSharedGoods Example from the author:第一次运行: Install-Module -Name PSSharedGoods作者的示例:

Get-ChildItem -Path $Env:USERPROFILE\Desktop -Force | Get-FileMetaData -Signature | Out-HtmlView -ScrollX -Filtering -AllProperties

Then this is how I was using their function:然后这就是我使用他们的 function 的方式:

$folder = Get-ChildItem
foreach($File in $folder) {
$fileMetaProperties = @($(Get-FileMetaData $File | Select-Object -Property Name,Title))
$a = $fileMetaProperties.Name
$b = $fileMetaProperties.Title
Write-Output "$a and $b"
}

Good Luck!祝你好运!

As I answered in your another question, you could try this for the hash column正如我在您的另一个问题中回答的那样,您可以在hash列中尝试此操作

 $FolderItems = Get-PnPFolderItem -FolderSiteRelativeUrl $FolderURL -ItemType File -Recursive
 ForEach($File in $FolderItems){
    $File.Name
    $fileURL=$FolderURL+"/"+$File.Name
    $fileItem=get-pnpfile $fileURL -AsListItem
    $fileItem['Hash']
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM