Create a sql command object
          This function uses the information contained in the parameters to create a sql command object. In general, you will want to use the invoke- functions directly,
          but if you need to manipulate a command object in ways that those functions don't allow, you will need this. Also, the invoke-bulkcopy function allows you to pass
          a command object instead of a set of records in order to "stream" the records into the destination in cases where there are a lot of records and you don't want to
          allocate memory to hold the entire result set.
      .PARAMETER sql
          The sql to be executed by the command object (although it is not executed by this function).
      .PARAMETER connection
          An existing connection to perform the sql statement with.
      .PARAMETER parameters
          A hashtable of input parameters to be supplied with the query. See example 2.
      .PARAMETER timeout
          The commandtimeout value (in seconds). The command will fail and be rolled back if it does not complete before the timeout occurs.
      .PARAMETER Server
          The server to connect to. If both Server and Connection are specified, Server is ignored.
      .PARAMETER Database
          The initial database for the connection. If both Database and Connection are specified, Database is ignored.
      .PARAMETER User
          The sql user to use for the connection. If both User and Connection are specified, User is ignored.
      .PARAMETER Password
          The password for the sql user named by the User parameter.
      .PARAMETER Transaction
          A transaction to execute the sql statement in.
          PS C:\> $cmd=new-sqlcommand "ALTER DATABASE AdventureWorks Modify Name = Northwind" -server MyServer
          PS C:\> $cmd.ExecuteNonQuery()
          PS C:\> $cmd=new-sqlcommand -server MyServer -sql "Select * from MyTable"
          PS C:\> invoke-sqlbulkcopy -records $cmd -server MyOtherServer -table CopyOfMyTable
          You cannot pipe objects to new-sqlcommand

  function New-SQLCommand{
        $dbconn=Get-Connection -conn $connection -server $server -database $database -user $user -password $password
        $close=($dbconn.State -eq [System.Data.ConnectionState]'Closed')
        if ($close) {
        $cmd=new-object system.Data.SqlClient.SqlCommand($sql,$dbconn)
        foreach($p in $parameters.Keys){
            if (Test-NULL $parameters[$p]){
        Set-outputparameters $cmd $outparameters
        if ($transaction -is [System.Data.SqlClient.SqlTransaction]){
        $cmd.Transaction = $transaction
        return $cmd