I created thisscriptinPowershellto read aDBrecord andcreate ahashof itsaltyand insert it backin atable,goodscriptworksfine the wayI need,butwhat sticksis the delay9 millionrecordtwo days.I needifanyone has anycommand thatcouldmake it fasterto things.
Whohas littlerecord andwant to usethis scriptare comfortableit works.
$user = "user"
$pwd = "pws"
$database = "bdd"
$SqlServer = "round"
$SqlLogs = "T_Powershll"
$Date = (Get-Date -format g)
$SqlConnection = New-Object system.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString ="Server=$dataSource;uid=$user; pwd=$pwd;Database=$database;Integrated Security=False;"
$SqlConnection2 = New-Object system.Data.SqlClient.SqlConnection("Server=$dataSource;uid=$user; pwd=$pwd;Database=$database;Integrated Security=False;")
$seq=1
$fim=9561421
While ($seq -le $fim){
$SqlCommandText = "Select Cartao from T_Powershll_base where Id_seq= $seq "
$SqlConnection.Open()
$SqlConnection2.Open()
$SqlCmd = New-Object Data.SqlClient.SqlCommand($SqlCommandText, $SqlConnection)
$sqlcmd2 = $SqlConnection2.createcommand()
$Reader = $SqlCmd.ExecuteReader()
$SqlData = @( )
while ($Reader.Read())
{
$SqlData += "" | Select-Object `
@{ n = 'Cartao' ; e = { $Reader["Cartao"].ToString() } }
}
$Reader.Close()
$sha1 = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider;
$sha1.Initialize();
$Salgado="710000hhgiiAAAhhhhooohzaqnpa
epszx7w2soPmdfapa)gbbakkazwq
"
$cart=$SqlData.Cartao
$cart2=[System.Text.Encoding]::ASCII.GetBytes($cart.PadRight(32,'_'));
$lim4=[System.Convert]::FromBase64String($Salgado.ToString());
$ab =$sha1.ComputeHash($cart2+$lim4);
$HASH="{0}" -f [system.BitConverter]::ToString($ab)-replace "-",""
$sqlcmd2.CommandText = "INSERT INTO $SQLLogs (Cartao, Cartao_Hash) VALUES ('$($SqlData.Cartao)', '$($HASH)')"
$Results = $SqlCmd2.ExecuteNonQuery()
$seq++
$SqlConnection.close()
$SqlConnection2.close()
}
TKS.