Post date: Oct 27, 2011 10:36:19 AM
This is a short example of how to take every .sql script file in a directory and create one big file from their content. Between every file we will add the GO statement and a NewLine.
Get All Files in $path
For each file
Read all the text content
Append "GO"
Append a NewLine
Write the result to the output file
$path = ".\src\"$outputFile = "..\out.sql"[System.IO.Directory]::GetFiles($path) | ForEach-Object { [System.IO.File]::ReadAllText($_) + [Environment]::NewLine + "GO " + [Environment]::NewLine } | out-file -filepath $outputFile -append