在以下代码中,我收到错误
无法转换" Microsoft.SharePoint.Client.FieldLookupValue"类型的值" Microsoft.SharePoint.Client.FieldLookupValue"键入" Microsoft.SharePoint.Client.FieldLookupValue"。
我正在按照我在此处找到的代码来获取查找值。
$myContext = Get-PnPContext
$ELWeb = $myContext.Web
$siteReqListName = "ClassCreation"
$queryStr =
"<View>
<Query>
<Where>
<Eq>
<FieldRef Name='Subsite_x0020_Created'/>
<Value Type='Integer'>0</Value>
</Eq>
</Where>
</Query>
</View>"
$sites = @()
$sites = Get-PnPListItem -List $siteReqListName -Query $queryStr -Web $ELWeb
Disconnect-PnPOnline
foreach ($site in $sites) {
$itemId = $site["ID"]
$siteTitle = $site["Title"]
$lookup = [Microsoft.SharePoint.Client.FieldLookupValue]$site["Class_x0020_Category"]
$lookupValue=$lookup.LookupValue
}