0

I want to access DB variables using Serverspec, but in Serverspec for Windows it is not supported so I am trying using PowerShell but got the following issues

Tried using below powershell command:

"cd Program\ Files\\MySQL\\MySQL\ Server\ 5.5\\bin";
"\.\mysql.exe --user=root --password=atmf"

But not recognized due to escape characters issue and later if we give the command in double quotes PowerShell prints it as string.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328

1 Answers1

0

Just have the commandline client output the variable:

$mysql  = "C:\path\to\mysql.exe"

$dbuser = "root"
$dbpass = "..."
$dbname = "database"
$dbvar  = "innodb_buffer_pool_size"

$value = & $mysql -u "$dbuser" -p "$dbpass" -B -D "$dbname" -e "SELECT @@$dbvar"
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328