im writing an a Login Script that gets some Computer Information and pushes the Information to a SQL Express Database, every time a user logs on to the System
So I can grab the Information with Excel or another frontend and sort it by Computername or OU or something else.
- At first, I generate a small Report
- Check if the Hostname is already in my Database (function New-SQLCheck) If it is, update (function New-SQLUpdate) This is where I need help. if not create a new entry. (function New-SQLInsert)
This is working at the Moment, but the script takes very long to process and I think it s not really professional coded( I´m no programmer, but I learn fast )
Is it possible that you look over my Code and give me advise specially for the part where I UPDATE a hostname?--> UPDATE INVENTORY SET OSName='OBject1" 'Object2' 'Object3' ect..
I want to update the complete array of my Report@() instead of updating every single Object, ´cause in the feature there are coming more and more objects that we want to push.
I hope you see what I mean
Here are the neccessary parts of my code
Hello cmartin and thanks for taking the time to look over the Code.Theres only one row that is generated or updated.It is like this.A User logs on his workstationThe Script generates this Little Report and saves it to that Array @Report
Then I look in the database for the hostname, if it exists, the row will be updated, if not, a new one will be created.Thats all, for now.
My Problem is
a) I want to make it as time efficient as possibleb) I want to make the update process easier. Im enumerating all objects of my Report to update the SQL.Isnt it possible to say : ~ Update Inventory with @Report where Hostname = ... the same way I do it with INSERT INTO..?Or to Loop through my Report and update..
How would you Insert or Update a Database with an Array ?Could you please give me an example?thanks in advance
Powered by IDERA