[void][reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo");

#Set the server to script from 
$ServerName = ".";

$Queries = Get-Content -Delimiter "------" -Path "AdventureWorks BOL Workload.sql"

WHILE(1 -eq 1)
{
	$Query = Get-Random -InputObject $Queries;

	#Get a server object which corresponds to the default instance 
	$srv = New-Object -TypeName Microsoft.SqlServer.Management.SMO.Server $ServerName
	$srv.ConnectionContext.set_ConnectionString("Data Source=SQL2K14-IE2;Initial Catalog=AdventureWorks2014;User Id=aw_webuser;Password=abc123;Application Name=AdventureWorks Online Ordering;Workstation ID=AWWEB01");
	
	[Void]$srv.ConnectionContext.ExecuteNonQuery($Query);
	$srv.ConnectionContext.Disconnect();
	
	Start-Sleep -Milliseconds 100 
}

# Set-executionpolicy unrestricted