powershell - PnP PowerShell 代码语法错误问题
问题描述
我有一个函数可以遍历文档库并创建一个列出与每个项目关联的元数据的报告。
它不会编译。在第一个括号的函数声明中,我收到一个错误:
Missing closing '}' in statement block or type definition
我已经确定了似乎是错误来源的代码行。当我在 # 之间的行上剪切代码时,错误就消失了。
我无法弄清楚语法不正确的地方。我在用着:
SharePointPnPPowerShell2013 3.11.1907.0
function PopulateData($web, $incldeFileSize) {
Write-Host "Current Site " $web.url -ForegroundColor Cyan
$libs = Get-PnPList -Web $web | Where{($_.BaseType -eq “DocumentLibrary”) -or ($_.Title -eq "Pages") }
foreach($lib in $libs){
$libitems = (Get-PnPListItem -Web $web -List $lib -Fields "FileLeafRef","Name","Title","Author","Modified","Created","KBAbstract","KBContentAuthor","KBCategory","Publish","KBPublishDate").FieldValues
foreach($libitem in $libitems)
{
if($libitem.FSObjType -eq "0"){
$data = @{
"Web Name" = $web.Title
"Library Name" = $lib.Title
"File Name" = $libitem.FileLeafRef
"Abstract" = $libitem.KBAbstract
"Content Author" = $libitem.KBContentAuthor.Email
############The Problem is somewhere in these Lines of code###########
[Microsoft.SharePoint.Taxonomy.TaxonomyFieldValueCollection]$MMSFieldValueColl = $libitem.KBCategory
$MMSFieldTerms = ""
Foreach($MMSFieldValue in $MMSFieldValueColl)
{
if($MMSFieldValue.label -ne $null)
{
$MMSFieldTerms+=$MMSFieldValue.label+"; "
}
}
write-host $MMSFieldTerms
##########The Problem ends here############
"Knowledge Area" = $libitem.KBCategory
"Publish" = $libitem.Publish
"Published Date" = $libitem.KBPublishedDate.LookupValue
"File URL" = $libitem.FileRef
"Modified Date" = $libitem.Modified
"Created By" = $libitem.Author.LookupValue
"Created Date" = $libitem.Created
"Modified By" = $libitem.Editor.LookupValue
"File Size (KB)" = $null
}
if($incldeFileSize -eq $true){
$file = Get-PnPFile -Url $libitem.FileRef
$data["File Size (KB)"] = $file.Length / 1KB
}
New-Object PSObject -Property $data
}
}
}
}
解决方案
推荐阅读
- spring - Spring MVC 中最好的 HandlerMapping 是什么?
- jquery - fancybox V3 + isotope 排序依据
- vba - 将多个文本框值传输到数组
- php - 替换 HTML 标记内外的文本
- sqlalchemy - 在 Alembic + SQLAlchemy 中使用反射表进行自动迁移
- python - 如何从列表列表和另一个列表创建字典?
- android - 使用进度通知在后台连续上传文件到 Firebase 存储
- sql - 将旧值插入审计表的 SQL 更新触发器,仅在更新两个特定列时触发,否则返回错误
- php - Symfony 3.4 供应商自动装配
- javascript - 删除firebase中字段的特定部分(Angular)