1

I am setting the Hidden property to "True" at the end of this code, however, it continues to be displayed in the Report Manager interface. Does anyone know how to set this property using PowerShell with ReportService2010?

     $reportServerUri = "http://local/ReportServer_SQL2014/ReportService2010.asmx?wsdl"
     $rs = New-WebServiceProxy -Uri $reportServerUri -UseDefaultCredential 

     $proxyNamespace = $rs.GetType().Namespace

     $targetFolderPath = "/My Reports"
     $targetDatasourceRef = "/SharedDataSources/sdsHP"
     $warnings = $null
     $sourceFolderPath = "C:\Reports"

     Get-ChildItem $sourceFolderPath -Recurse -Filter "*.rdl" | Foreach-Object {
$reportName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
$bytes = [System.IO.File]::ReadAllBytes($_.FullName)

Write-Output "Uploading report ""$reportName"" to ""$targetFolderPath""..."
$report = $rs.CreateCatalogItem(
    "Report",         # Catalog item type
    $reportName,      # Report name
    $targetFolderPath,# Destination folder
    $true,            # Overwrite report if it exists?
    $bytes,           # .rdl file contents
    $null,            # Properties to set.
    [ref]$warnings)   # Warnings that occured while uploading.

$warnings | ForEach-Object {
    Write-Output ("Warning: {0}" -f $_.Message)
}

# Set the Hidden property of the reports.
     $report.Hidden = "True" 
     $report.HiddenSpecified = "True"

}         
Gimli
  • 41
  • 7

3 Answers3

1

It is more involved but works for me, using SMO:

   # Set the Hidden property of subreports using SMO.
    $smodb = New-Object Microsoft.SqlServer.Management.Smo.Database
    $smodb = $smoServer.Databases.Item("ReportServer")
    $smodb.ExecuteNonQuery("UPDATE ReportServer.dbo.Catalog SET Hidden =1 WHERE [Name] = '$ReportName' AND [Type] =2;") 
Gimli
  • 41
  • 7
0

Set property before report upload:

    $type = $rs.GetType().Namespace
    $datatype = ($type + '.Property')

    $HiddenProp = New-Object($datatype)
    $HiddenProp.Name = 'Hidden'
    $HiddenProp.Value = 'true'
    $Properties = @($HiddenProp)

$report = $rs.CreateCatalogItem(
"Report",         # Catalog item type
$reportName,      # Report name
$targetFolderPath,# Destination folder
$true,            # Overwrite report if it exists?
$bytes,           # .rdl file contents
$Properties,      # Properties to set.
[ref]$warnings)   # Warnings that occurred while uploading.
0

I know this is Old, But I had to Solve this today and the answers here didn't get me what I wanted.

I used RSTools to Make the Soap Proxy and get the catalog Items. If you don't already Have it installed Invoke-Expression (Invoke-WebRequest https://aka.ms/rstools)

Function Get-RSItemProperties
{
    param ( [System.Web.Services.Protocols.SoapHttpClientProtocol]$Proxy,[string]$RsItemPath )
    $server.Proxy.GetProperties($RsItemPath, $null)
}
Function Get-RSItemProperty
{
    param ( [System.Web.Services.Protocols.SoapHttpClientProtocol]$Proxy,[string]$RsItemPath,[string]$PropertyName )
    Get-RSItemProperties -Proxy $Proxy -RsItemPath $RsItemPath | Where-Object { $_.Name -eq $PropertyName }
}
Function Set-RSItemProperty
{
    param([System.Web.Services.Protocols.SoapHttpClientProtocol]$Proxy,[string]$RsItemPath,[Object[]]$Property)
    $PropertyName = $Property.Name
    $PropertyValue = $Property.Value
    try
    {
        Write-Verbose "Updating $RSItemPath $PropertyName Setting Value to $PropertyValue..."
        $Proxy.SetProperties($RsItemPath, $Property)
    }
    catch
    {
        throw (New-Object System.Exception("Exception occurred while $RSItemPath $PropertyName! $($_.Exception.Message)", $_.Exception))
    }
}
Function Set-RSItemHidden
{
    param([System.Web.Services.Protocols.SoapHttpClientProtocol]$Proxy,[string]$RsItemPath,[bool]$Hide=$True)
    $PropertyName = 'Hidden'

    if ( $Hide )
    {
        $Value = 'True'
    }
    else 
    {
        $Value = 'False'
    }

    $Property = Get-RSItemProperty -Proxy $Proxy -RSItemPath $RSItemPath -PropertyName $PropertyName
    $Property.Value = $Value
    Set-RSItemProperty -Proxy $server.Proxy -RsItemPath $RSItem.Path -Property $Property
}

Function Set-RSAllItemsHidden
{
    param([System.Web.Services.Protocols.SoapHttpClientProtocol]$Proxy)
    $UnHiddenItems = Get-RsCatalogItems -Proxy $Proxy -RsFolder / -Recurse | where-Object Hidden -eq $False
    foreach ( $RSItem in $UnHiddenItems)
    {
        Set-RSItemHidden -Proxy $Proxy -RsItemPath $RsItem.Path
    }

}

$Proxy = New-RsWebServiceProxy -ReportServerUri 'https://ReportServerName.YourDomain.com/Reportserver'

Set-RSAllItemsHidden -Proxy $Proxy