This is a product defect (TF00612888).
Steps to Recreate:
Run the following script in a workflow,
$connectionString = "Server=<SQLServerName>;Database=ActiveRoles;user id=sa;password=password;";
foreach($Record in (ExecuteQuery $connectionString))
$Record >> "rows.txt";
$connection = New-Object system.data.SqlClient.SQLConnection;
$connection.ConnectionString = $connectionString;
$cmd = $connection.CreateCommand();
$cmd.CommandText = "SELECT * FROM [dbo].[ViewsContent]";
$cmd.Connection = $connection;
$reader = [System.Data.SqlClient.SqlDataReader] $cmd.ExecuteReader();
The text file does not get created
The text file should be created with values in it
The script should work with Active Roles when debugging is disabled.