How to tell if the item language is the fallback language or the regular language version using a PowerShell script
3 Answers
You can check item is a fallback item, through reading IsFallback
property available on the item as below.
$item = Get-Item -Path "master:" -ID "{{Item_ID}}"
Write-Host $item.IsFallback
This will return true
if the item is a fallback item.
Hope this helps!!!
Language fallback can be checked by the Item.IsFallback
property, which returns true if the item is a fallback item.
I didn't test it in Powershell but you can try it by the IsFallback
property.
Thank you for your posts. I tried many different ways. But many cases did not work. The following steps worked.
# Iterate over all languages of the item
foreach ($language in $item.Languages)
{
# Get the item in the current language
$itemInLanguage = Get-Item -Path $item.Paths.Path -Language $language
# Check if count greater than 0 or not
if ($itemInLanguage.Count -gt 0) {
Write-Host "version found in language: $language"
} else {
Write-Host "no version found or fallback version in language: $language"
}
}