I am trying to use SimplySQL example from their wiki, to connect to MySQL Server which is up and running (MySQL Workbench works fine)
# | Load and Install SimplySQl Module from PSGallery
Install-Module SimplySql -Scope CurrentUser
# Импорт модуля SimplySQL
Import-Module -Name SimplySQL
$password = ConvertTo-SecureString "secpwd" -AsPlainText -Force
[pscredential]$Cred = New-Object System.Management.Automation.PSCredential ("sqlwriter", $password)
Open-MySqlConnection -server '192.168.0.70' -connectionname 'localhost' -database 'mydb' -Credential Cred
$testconnection = Test-SqlConnection -ConnectionName 'localhost'
$InsertQuery = "INSERT INTO table1 (value1, value2) VALUES (@label1, @label2)"
Close-SqlConnection -connectionname 'localhost'
I have an error:
Open-MySqlConnection: Failed to bind parameter 'Credential'. Cannot convert value "Cred" of type "System.String" to type "System.Management.Automation.PSCredential".
Obviously, there is someting wrong with this credential object, but what? It completely mimicks microsoft tutorial. I just do not understand why it can not transform to secure string while it is stated in script. wtf…