Protect-String throws when module path contains spaces

Create issue
Issue #174 resolved
Simon Garratt created an issue

On my machine, Carbon (2.0.1) is installed here:

C:\Program Files\WindowsPowerShell\Modules\Carbon\

When I run:

$me = Get-credential 'DOMAIN\User1'
Protect-String -String 'This is a string' -Credential $me

I see

Protect-String : C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file,
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ C:\Program Files\WindowsPowerShell\Modules\Carbon\bin\Protect-String.ps1 -Protec ...
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Program:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

At line:1 char:1
+ Protect-String -String 'This is a string' -Credential $me
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Protect-String

Comments (5)

  1. Simon Garratt reporter

    I resolved it by changing -ArgumentList to:

    -ArgumentList "-File `"$protectStringPath`"", '-ProtectedString', $encodedString `
  2. Log in to comment