PowerShell – Update SQL Record

email me

This is how you update a record in a database using PowerShell. I’m using this to modify the OS field, which is sometimes delayed due to slow inventory scans.

Note, where it says “The_”, I recommend using variables in your scripting.

Set-Location SQLSERVER:\SQL\The_SQL_Server_Name\The_SQL_Instance
Invoke-Sqlcmd -Query "UPDATE dbo.vSMS_R_System SET Operating_System_Name_and0 = 'Microsoft Windows NT Workstation 10.0' WHERE Name0='The_Computer_Name'" -Database "The_SCCM_DB_Name"