Posh-ACME.Deploy icon indicating copy to clipboard operation
Posh-ACME.Deploy copied to clipboard

Add module for Power BI Reporting Services

Open Twenix83 opened this issue 11 months ago • 5 comments

This adds Set-PBIRSCertificate. Usage is the same as most of the other modules. Tested with Power BI Report Server 15.0.1105.195.

Twenix83 avatar Jan 29 '25 17:01 Twenix83

Thanks for the PR, @Twenix83. It might be a bit before I can look at this because there's some other issues and PRs I've been slacking on that are higher priority. But we'll get there.

rmbolger avatar Jan 30 '25 16:01 rmbolger

Okay, thank you! Meanwhile I can script modules for MSSQL and such, so that you don't get bored :-)

Twenix83 avatar Jan 30 '25 17:01 Twenix83

So fair warning, I know absolutely zero about PowerBI. Do you know of any guides out there for doing a quick barebones setup, so I can test things out? The code makes it look like we're just tweaking certs for MSSQL under the hood. Is there value in having a PowerBI specific function over a more generic MSSQL one?

Alternatively, would having a generic MSSQL function allow simplifying the PowerBI function by wrapping the MSSQL one with some extra defaults and logic?

After a quick skim of the code, the main thing I'd like to tweak is the use of the Get-WMIObject function. I've been trying to keep everything using the equivalent CIM function, Get-CIMInstance which is newer and more future-proof.

rmbolger avatar Feb 23 '25 08:02 rmbolger

It looks like the Get-WMIObject calls can be replaced outright with Get-CimInstance using the same parameters. So this

    # Get the name of the PBIRS server
    $PBIRSServerName = (Get-WmiObject -Namespace root\Microsoft\SqlServer\ReportServer -Class __Namespace).Name
    # Get the version of the PBIRS server
    $PBIRSVersion = (Get-WmiObject -Namespace root\Microsoft\SqlServer\ReportServer\$PBIRSServerName -Class __Namespace).Name
    # Get the configuration of the PBIRS server
    $PBIRSConfig = Get-WmiObject -Namespace "root\Microsoft\SqlServer\ReportServer\$PBIRSServerName\$PBIRSVersion\Admin" -Class MSReportServer_ConfigurationSetting

Can be replaced by this:

    $rsRoot = $rsRoot = "root\Microsoft\SqlServer\ReportServer"
    # Get the name of the PBIRS server
    $PBIRSServerName = (Get-CimInstance -Namespace $rsRoot -Class __Namespace).Name
    # Get the version of the PBIRS server
    $PBIRSVersion = (Get-CimInstance -Namespace $rsRoot\$PBIRSServerName -Class __Namespace).Name
    # Get the configuration of the PBIRS server
    $PBIRSConfig = Get-CimInstance -Namespace "$rsRoot\$PBIRSServerName\$PBIRSVersion\Admin" -Class MSReportServer_ConfigurationSetting

It also probably makes more sense to replace the hard coded DE locale with whatever is current:

$lcid = [System.Globalization.CultureInfo]::CurrentCulture.LCID

The WMI method calls work a bit differently though since you can't just call them directly from the CimInstance returned objects. It looks like you need to call them using Invoke-CimMethod like this for example:

$WebApplications = (Invoke-CimMethod -InputObject $PBIRSConfig -MethodName ListSSLCertificateBindings -Arguments @{lcid=$lcid}).Application

rmbolger avatar Feb 23 '25 19:02 rmbolger

Sorry for the late response. I am very busy atm.

So fair warning, I know absolutely zero about PowerBI. Do you know of any guides out there for doing a quick barebones setup, so I can test things out? The code makes it look like we're just tweaking certs for MSSQL under the hood. Is there value in having a PowerBI specific function over a more generic MSSQL one?

Alternatively, would having a generic MSSQL function allow simplifying the PowerBI function by wrapping the MSSQL one with some extra defaults and logic?

PowerBI Reporting Services is a web server software that is included in the same installer disc, but it is a diferent product. Under the hood it seems to be IIS (because of using web.config and so on). I think that configuring it via an extra parameter in a generic MSSQL module makes it more complicated.

It looks like the Get-WMIObject calls can be replaced outright with Get-CimInstance using the same parameters. So this

    # Get the name of the PBIRS server
    $PBIRSServerName = (Get-WmiObject -Namespace root\Microsoft\SqlServer\ReportServer -Class __Namespace).Name
    # Get the version of the PBIRS server
    $PBIRSVersion = (Get-WmiObject -Namespace root\Microsoft\SqlServer\ReportServer\$PBIRSServerName -Class __Namespace).Name
    # Get the configuration of the PBIRS server
    $PBIRSConfig = Get-WmiObject -Namespace "root\Microsoft\SqlServer\ReportServer\$PBIRSServerName\$PBIRSVersion\Admin" -Class MSReportServer_ConfigurationSetting

Can be replaced by this:

    $rsRoot = $rsRoot = "root\Microsoft\SqlServer\ReportServer"
    # Get the name of the PBIRS server
    $PBIRSServerName = (Get-CimInstance -Namespace $rsRoot -Class __Namespace).Name
    # Get the version of the PBIRS server
    $PBIRSVersion = (Get-CimInstance -Namespace $rsRoot\$PBIRSServerName -Class __Namespace).Name
    # Get the configuration of the PBIRS server
    $PBIRSConfig = Get-CimInstance -Namespace "$rsRoot\$PBIRSServerName\$PBIRSVersion\Admin" -Class MSReportServer_ConfigurationSetting

To be fair: I am no expert at WMI and CIM. I searched different guides and with my general knowledge I assembled it to a working code. At the first view your code looks good in my eyes. I could test it if I find the time.

It also probably makes more sense to replace the hard coded DE locale with whatever is current:

$lcid = [System.Globalization.CultureInfo]::CurrentCulture.LCID

You are absolutely right. I don't know why I don't have it in the pull request because I also used it during testing.

Another discussion but my problem is that I really like your your module, but at the moment we are configuring our whole environment via ansible which often uses DSC for things. And a nice DSC module for configuring certificates should be much better for us than the command approach. But both approaches have their use cases.

Twenix83 avatar Mar 05 '25 07:03 Twenix83