I am using powershell_script resource in chef to create a database in sqlserver 2012 here.
I have used database name as test1 hardcoded in script. Now I want to provide the database name from the attribute file.
How can I get the value referenced from attribute file to the script.
powershell_script "create database" do
code <<-EOH
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
$serverName = "localhost"
$server = new-object ('Microsoft.SqlServer.Management.Smo.Server') $serverName
#Create a new database
$db = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Database -argumentlist $server, "test1"
$db.Create()
#Reference the database and display the date when it was created.
$db = $server.Databases["Test_SMO_Database"]
$db.CreateDate
EOH
end