Skip to content

Restore-RSEncryptionKey failing when credential is used #228

Closed

Description

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
I am getting this error when attempting to restore an encryption key on a remote system using an alternate credential:

Failed to restart Report Server database service. Manually restart it for the change to take effect! Cannot find any service with service name 'ReportServer'.

Restore-RSEncryptionKey does not properly handle restarting of the Reporting Services service when run from a remote system and using an alternate credential. The function incorrectly assumes that the user running the command has appropriate access to the Reporting Services system. This is reflected through the use of Get-Service, which does allow connecting to another system but not with alternate credentials:

$service = Get-Service -Name $reportServerService -ComputerName $rsWmiObject.PSComputerName -ErrorAction Stop

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Assuming that adminuser user has access to the computer SSRS and the user running the command does not, this will fail:

Restore-RSEncryptionKey -KeyPath 'C:\MyFolder\MyKeyFile.snk' -Password 'MyPass' -ComputerName SSRS -Credential (Get-Credential adminuser)

What is the expected behavior?
The function should handle situations with and without an alternate credential.

Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts?
Windows 10 Enterprise 1803 with PowerShell 5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions