Retrieve InstallationID from an XML document. Almost there but...

  • Hello,

    I am trying to automate the initialization of the Report Server in SSRS Configuration Manager using Powershell.

    So far I have worked out that I can use the InitializeReportServer Method which requires the InstallationID as a parameter. This can be found in the rsreportserver.config XML file and appears like this..

    <InstallationID>{d63c8ae2-003e-4f3e-bdae-faa7688b7a79}</InstallationID>

    ...so I retrieve it using this...

    $XML=[XML](Get-Content 'C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\rsreportserver.config')

    $InstID = $XML.DocumentElement | Select InstallationID

    $SSRSConMgr = Get-WmiObject -Namespace "root\Microsoft\SqlServer\ReportServer\RS_MSSQLSERVER\v11\Admin" -Class MSReportServer_ConfigurationSetting -ComputerName $env:COMPUTERNAME

    $SSRSConMgr.InitializeReportServer([string]$InstID)

    ...however, it returns the result with the curly braces included, so I get an error when I try to use the variable as a parameter...

    __GENUS : 2

    __CLASS : __PARAMETERS

    __SUPERCLASS :

    __DYNASTY : __PARAMETERS

    __RELPATH :

    __PROPERTY_COUNT : 2

    __DERIVATION : {}

    __SERVER :

    __NAMESPACE :

    __PATH :

    ExtendedErrors : {The parameter value provided for 'InstallationID' does not match the parameter type. (rsParameterTypeMismatch), Guid should contain 32 digits with 4 dashes

    (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).}

    HRESULT : -2146233088

    PSComputerName :

    ...so my questions is, how do I return the result, but exclude the curly braces?

    Any help, is as always, greatly appreciated.

    Kind regards,

    D.

  • Quick suggestion, replace the curlies out of the ID

    😎

    $InstID = $XML.DocumentElement | Select InstallationID

    $InstID = -replace "{", ""

    $InstID = -replace "}", ""

  • Hello,

    Thank you for replying, but unfortunately that did not work. I got the same error as I did previously.

    Anyone else? I'll keep looking.

    Regards,

    D.

  • Ok think I worked it out, I get so much help on this forum, I hope this helps somebody else.

    $SSRSConMgr = Get-WmiObject -Namespace "root\Microsoft\SqlServer\ReportServer\RS_<yourInstanceNameOrVariableHere>\v11\Admin" -Class MSReportServer_ConfigurationSetting -ComputerName $env:COMPUTERNAME

    $SSRSConMgr.InitializeReportServer("$InstID".TrimStart('@{InstallationID={').TrimEnd('}'))

    Gives me a HRESULT of 0.

    Regards,

    D

    How to remove curly braces from InstallationID initializing SSRS SQL Server Reporting Services with PowerShell

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply