microsoft / ReportingServicesTools

Reporting Services Powershell Tools
MIT License
458 stars 213 forks source link

Issue with Resolve-Path in Restore-RSEncryptionKey #384

Closed Gavster4 closed 2 years ago

Gavster4 commented 2 years ago

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

What is the current behavior? On using a UNC path for KeyPath, the result of Resolve-Path prepends the path with "Microsoft.PowerShell.Core\FileSystem::" which breaks the subsequent [System.IO.File]::ReadAllBytes($KeyPath).

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Save the snk key file to a UNC path and pass that into the function as "\domain\share\folder\keyfile.snk".

Incorrect result:

Exception calling "ReadAllBytes" with "1" argument(s): "The given path's format is not supported."
At line:16 char:13
+             $keyBytes = [System.IO.File]::ReadAllBytes($KeyPath)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : NotSupportedException

What is the expected behavior? The result should pass in the UNC path starting at the "\" characters.

Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts? Unsure if this was working prior. This was discovered on a new implementation of this module.