Hi All,
I am new to SQL query, But I have a requirement of updating/inserting data depending on values in a table.
My requirement is,
We have few computers which will update hostname, admin password (reset and update) and user logged on every machine startup. Script look like
=====================================================
$SQLServer = "server\SQLEXPRESS" #use Server\Instance for named SQL instances!
$SQLDBName = "Admin_PWD"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; Integrated Security = false; UID=adminpass; PWD=xxxx@123"
$SqlConnection.Open()
$execute_query = New-Object System.Data.SqlClient.SqlCommand
$execute_query.connection = $SqlConnection
# $execute_query.commandtext = $insert_query
$execute_query.CommandText = "INSERT INTO AdminPass (Comp_Name,Password,user) VALUES ('$computer','$strPassword','$user')"
$execute_query.executenonquery()
$SqlConnection.Close()
=====================================================
Here issue is it is creating new entries every restart. I need existing computer information to be updated with user and Password info and New computers to be inserted in to table. Howe it is possible with above script?
Regards, Vipin Vasudevan