Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSInvalidCastException: Cannot convert the "dummystring" value of type "System.String" to type "System.Security.SecureString" #1

Open
MisinformedDNA opened this issue Apr 18, 2019 · 1 comment

Comments

@MisinformedDNA
Copy link

I get this error when I try to use your script:

Context Azure API Validation
  [-] Error occurred in Context block 0ms
    PSInvalidCastException: Cannot convert the "dummystring" value of type "System.String" to type "System.Security.SecureString".
    ParameterBindingException: Cannot bind parameter 'sqlServerAdminPassword'. Cannot convert the "dummystring" value of type "System.String" to type "System.Security.SecureString".
    at <ScriptBlock>, C:\repos\ecommerce2\deploy\Atlas.Ecommerce.Deployment\azuredeploy.tests.ps1: line 188
    at DescribeImpl, C:\Users\50587\Documents\WindowsPowerShell\Modules\Pester\4.7.3\Functions\Describe.ps1: line 199

Here are some snippets of my ARM files:

azuredeploy.parameters.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "sqlServerAdminPassword": { "value": "This is a password!" }
  }
}

azuredeploy.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "sqlServerAdminPassword": {
      "type": "securestring"
    }
  }
}
@vegar
Copy link

vegar commented Jun 18, 2019

I solved this by modifying the script a little:

Around line 163:

"securestring" {
  [Security.SecureString]$secureValue = (ConvertTo-SecureString "P@ssW0rD!" -asplaintext -force)
  $TemplateParameters.Add($Parameter, $secureValue)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants