Poderia ser algo assim: (Adicione sua lógica para alternar entre tabelas e etc.)
$userInput = read-host "exception"
$exceptArray = $userInput -split ","
foreach($allowedSchema in $allowedArray){
if($exceptArray -notcontains $allowedSchema){
$sqlString = "select * from [" + $allowedSchema + "].[tableName]"
$connection = New-Object System.Data.SQLClient.SQLConnection
$connection.ConnectionString = "server={serverName}\{instanceName};database={databaseName};trusted_connection={true\false};"
$connection.Open()
$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmd.Connection = $connection
$cmd.CommandText = $sqlString
$resultSet = $cmd.ExecuteReader()
}
}