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
I should have spent more time looking. It looks like you call New-SQLCheck each time you have a new set to process. That means that you have to open a new connection to the database each time, and that is a time consuming operation.
If that's what is going on, try opening $conn just once and then pass it into New-SQLCheck as a parameter. That will streamline things a bit.
Powered by IDERA