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"

}         
4

3 回答 3

1

它涉及更多,但对我有用,使用 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;") 
于 2016-09-08T23:17:46.013 回答
0

在报告上传之前设置属性:

    $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.
于 2020-05-18T13:56:03.583 回答
0

我知道这是旧的,但我今天必须解决这个问题,这里的答案并没有让我得到我想要的。

我使用 RSTools 制作 Soap 代理并获取目录项。如果您还没有安装它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


于 2020-05-27T15:32:10.263 回答