function exec_ps($sqlserver_psname, $ps_NoUniteOrg , $ps_AnSession, $ps_NoCohorteFC,$ps_NbreMois ,$ps_NbreAnnee ) { $connString = "Data Source=" + $sqlserver_servername + ";Initial Catalog=" + $sqlserver_database + ";User Id=$sqlserver_user; Password=$sqlserver_pwd;" $SQLConnection = New-Object System.Data.SqlClient.SqlConnection $SQLConnection.ConnectionString = $ConnString $SQLCmdString = "dbo.$sqlserver_psname" $SQLCmdTimeout = 120 $SQLCmd = New-Object System.Data.SqlClient.SqlCommand $SQLCmd.CommandType = [System.Data.CommandType]::StoredProcedure $SQLCmd.CommandText = $SQLCmdString $SQLCmd.CommandTimeout = $SQLCmdTimeout $SQLCmd.Connection = $SQLConnection $SQLCmd.Parameters.AddWithValue("@anSession", $ps_AnSession) | Out-Null $SQLCmd.Parameters.AddWithValue("@noCohorteFC", $ps_NoCohorteFC) | Out-Null $SQLCmd.Parameters.AddWithValue("@noUniteOrg", $ps_NoUniteOrg) | Out-Null if($sqlserver_psname == "CoursGroupeFinCohort"){ $SQLCmd.Parameters.AddWithValue("@nbreMois", $ps_NbreMois) | Out-Null $SQLCmd.Parameters.AddWithValue("@nbreAnnee", $ps_NbreAnnee) | Out-Null } $SQLConnection.Open() $SQLCmd.ExecuteNonQuery() | out-null $SQLConnection.Close() } #CoursGroupeEtudiant #CoursGroupeEnseignant #CoursGroupeTitreCours #CoursGroupeFinCohort $ps= "CoursGroupeEtudiant" $noUniteOrg = "915000-1" $AnSe= 0 $Cohorte = "0" $nbreMois = 0 $nbreAn = -1 function exec_ps($ps, $noUniteOrg, $AnSession , $CohorteFC, $nbreMois, $nbreAn)