Quantcast
Channel: All about Microsoft Endpoint Manager
Viewing all articles
Browse latest Browse all 444

How to fix duplicate reports with double underscore (__) in Configuration Manager

$
0
0

The other day, I was running the ConfigMgr reports in my lab, especially the asset intelligence reports for some hardware information.

I tried to run the first report __ Hardware 01A – Summary of computers in a specific collection, it did not run successfully.

The following is the error code.

The report server cannot process the report or shared dataset. The shared data source 'AutoGen__5C6358F2_4BB6_4a1b_A16E_8D96795D8602_' for the report server or SharePoint site is not valid. Browse to the server or site and select a shared data source. (rsInvalidDataSourceReference)

image

Based on the error code, the issue could be related to the shared data source. So when I checked data source properties for the report, it has no value configured in it.

The shared data source reference is no longer valid.

image

To fix this, click on the select a shared data source, select {5C6358F2-xxx}, click on Ok.

2021-07-23_22h33_24

Run the report now, it works fine.

image

Likewise, I run another report, it also had the same issue. This report also starts with a double underscore (__)

So I have searched with the first report to see if any duplicates. I got 2 entries.

2021-07-23_22h34_21

clip_image002

Based on this, I figured out, the reports with a double underscore (__) are duplicates of the original and might have happened during the upgrade of the Configuration manager site (2103).

Since the configuration site in my lab was upgraded to 2013 followed by the latest hotfix a few months ago, the logs are overwritten hence cannot find the root cause.

For now, I will need to figure out, how many reports are duplicated with a double underscore (__) and get rid of them (delete them).

The following is the SQL query for it.

Use ReportServer;
Select ItemID,Path,Name,ParentID,Type,Description,Hidden,CreatedByID,CreationDate,ModifiedByID,ModifiedDate,Parameter 
FROM dbo.Catalog
 WHERE Type = 2
 and name not like '[__]%'
 Order by Name

image

The following is the SQL query to get a list of reports without double underscore (__).

Use ReportServer;
Select ItemID,Path,Name,ParentID,Type,Description,Hidden,CreatedByID,CreationDate,ModifiedByID,ModifiedDate,Parameter 
 FROM dbo.Catalog
 WHERE Type = 2
 and name not like '[__]%'
 Order by Name

Before we take delete action, we can do a quick comparison (VLOOKUP/excel) to confirm these __ reports are duplicated or not.

There are about 250+ reports which have the same symptoms and these can be deleted.

Now, how do we remove these duplicate reports? Deleting one by one by going to each category based on the SQL data?

We can make sure of the PowerShell script to delete these reports in one go.

The following is the PowerShell script from the Technet forum.

#######################################################################################################################
# SCCM2012SP1-RemoveDuplicateSSRSReports.ps1
# This script will connect to SSRS on a specified server and delete all reports that begin with a double underscore
# Used for SSRS cleanup after SCCM 2012 SP1 installation
# Script must be run from an account that has access to modify the SSRS instance
# 2/15/2013 - Mike Laughlin
#
# Resources used in writing this script:
# Starting point: http://stackoverflow.com/questions/9178685/change-datasource-of-ssrs-report-with-powershell
# API Documentation: http://msdn.microsoft.com/en-us/library/ms165967%28v=sql.90%29.aspx
#######################################################################################################################

# Define variables
	$SiteCode = ""
	$serverName = ""

# Set the value of $noConfirm to $True only if you don't want to manually confirm report deletion. Use with caution.
	$noConfirm = $False

# Safeguard	
	If ( $SiteCode -eq "" -or $serverName -eq "" ) { Write-Host "Enter the required information for the SiteCode and serverName variables before running this script." -ForegroundColor Red -BackgroundColor Black ; Exit }

# Connect to SSRS
	$ssrs = New-WebServiceProxy -uri http://$serverName/ReportServer/ReportService2005.asmx?WSDL -UseDefaultCredential

# Get a listing of all reports in SSRS
	$reportFolder = "/ConfigMgr_" + $SiteCode
	$reports = $ssrs.ListChildren($reportFolder, $True)
	
# Find all reports starting with double underscores
	$reportsToDelete = $reports | Where { $_.Name.Substring(0,2) -eq "__" }
	
# Quit if no reports are found
	If ( $reportsToDelete.Count -eq 0 ) { Write-Host "No reports found. Quitting." ; Exit }
	
# Show a listing of the reports that will be deleted
	Write-Host "The following reports will be deleted from SSRS on" $serverName":`n"
	$reportsToDelete.Name
	Write-Host "`nTotal number of reports to delete:" $reportsToDelete.Count "`n"
	
# Get confirmation before deleting if $noConfirm has not been changed
	If ( $noConfirm -eq $False ) 
	{ 
		$userConfirmation = Read-Host "Delete these reports from" $serverName"? Enter Y or N"
		If ( $userConfirmation.ToUpper() -ne "Y" ) { Write-Host "Quitting, reports have not been deleted." ; Exit }
	}
	
# Delete the reports
	$deletedReportCount = 0
	
	Write-Host "Beginning to delete reports now. Please wait."
	ForEach ( $report in $reportsToDelete ) { $ssrs.DeleteItem($report.Path) ; $deletedReportCount++ } 
	Write-Host "Reports have been deleted. Total number of deleted reports:" $deletedReportCount

Hope this helps!


Viewing all articles
Browse latest Browse all 444

Trending Articles