3

I have a list with a Term field.

I want all Items that have the Term "Stationärer Bereich:Vertrieb" or "Stationärer Bereich:Vertriebsinnendienst" (Including the subtree Terms).

This is my Termset:

enter image description here

I try it with a CAML-Query and the Term-IDs, but it doesn't work.

$snapin = Get-PSSnapin | Where-Object {$_.Name -eq "Microsoft.SharePoint.Powershell"}
if ($snapin -eq $null)
{
    Write-Host “Loading SharePoint Powershell”
    Add-PSSnapin Microsoft.SharePoint.Powershell
}

$web = Get-SPWeb -Identity https://intranet/management/

$list = $web.Lists["Vertragsmanagement"]

$query = "<Where> 
        <in> 
            <FieldRef Name='Abteilungen' LookupId='TRUE' /> 
            <Values>
                <Value Type='Text'>ddb1773b-bc7c-4275-9313-e656a91a0c87</Value>
                <Value Type='Text'>35624345-3670-4de0-842b-7809f82682b0</Value>
                <Value Type='Text'>a6b9891e-cfce-42ce-a18b-2b5660442230</Value>
                <Value Type='Text'>a30d422e-ccab-457e-a219-3559bcc25421</Value>
                <Value Type='Text'>00bbcda2-85bf-4960-ac19-69f2d9c9a8a4</Value>
                <Value Type='Text'>0fb9ef14-3749-49f9-a99e-dd9bc0a7fa8a</Value>
            </Values>
        </in> 
    </Where>";

$itemcollection = $list.GetItems($query); 
foreach ($item in $itemcollection | select -first 5 ){
    $item.name;
    $item.Properties.Abteilungen;

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.