I am trying to execute the below power shell script to script out the db in sql server.
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
$s = new-object ('Microsoft.SqlServer.Management.Smo.Server') "SRVBLRDBATST98\MSSQLSERVER1"
$abc=$s.databases
foreach ($tables in $abc)
{
$tables.Script() | out-File e:\pruthvi\db.txt -Append
}
The above power shell will script the out put to db.txt, but i need the output like dbname.txt for each database which will be created everytime for each databases. any help?