With this powershell command you will be to get all the components with missing datasources in WEB DB.
##### Get all the components in WEB DB with Missing Datasource value ####
##### Important - RUN THE SCRIPT WITH WEB DB Context ####
$defaultLayout = Get-LayoutDevice -Default
$pages = get-item web:/sitecore/content/projectName/Home/Home/covid-19/business-and-organisations/resurgence-support-payment | get-childitem -Recurse
foreach($page in $pages)
{
$rootItem = Get-Item -Path "web:" -ID $page.ID
$renderingItems= Get-Rendering -Item $rootItem -Device $defaultLayout -FinalLayout
foreach ($renderingvalues in $renderingItems)
{
# if($renderingvalues.ItemID -eq "{C50DD667-8CBA-46F1-8DA8-C1233F025545}")
# {
$printDetails = $page.Paths.path + "," + $renderingvalues.Datasource
if($renderingvalues.Datasource)
{
if(($item = Get-Item -Path $renderingvalues.Datasource -ErrorAction SilentlyContinue))
{
# Write-Host "Datasource Item Found," $printDetails
}
else {
$currentRenderingDetails = Get-Item -Path $renderingvalues.ItemID
Write-Host "Datasource Item doesnt exist in WEB," $printDetails "," $currentRenderingDetails.Name
}
}
else
{
# $currentRenderingDetails = Get-Item -Path $renderingvalues.ItemID
# Write-Host "Datasource value is blank in WEB," $printDetails "," $currentRenderingDetails.Name
}
# }
}
}