📜 ⬆️ ⬇️

Another way to automate inventory

Imagine that you have a small office of 150 PCs on Windows, and the management desired to make a complete inventory of the existing park. Suppose you have several support staff for these tasks. What would you do?

The first thing that comes to mind is to hand a pen and a notebook to the technicians and send it to the fields. The idea is good, but rests on the "cost of downtime" and the complete lack of loyalty among employees in relation to technical support.

What to do and how to be in this situation? Another recipe under the cut

The second thought that occurred to me was “you can collect iron statistics remotely.” As the saying goes, the sheep will be safe and the wolves will be full. I found an excellent article on Habré for remote inventory, but the trouble is, you need domain administrator rights to work properly. I did not want to give superfluous rights to technicians, and began to invent a different solution.
')
I took the convenient automation language AutoIt 3.3.8.1 into my hands ( you can download it from here ), and the keyboard went straight to my feet. For the collection of reports, we will use the already tested for years solution based on the Aida64 Business Edition Trial ( You can download it from here ). Using Aida64 for our purposes does not violate the license agreement.

The work algorithm turned out to be rather banal and reliable, without crutches and perversions -
Create a temporary folder -> Copy from the "balls" and unpack the necessary components -> Start the report collector in text mode -> Copy the report to the "ball" for reports -> Delete traces from the computer

The code of the "client" part written in AutoIt. I will not post it here, it’s very ugly, it looks here in the text, I’ll post it on PasteBin - here’s the link



Compile it with the compiler included with AutoIt. The compiler is called “Aut2exe v3 - AutoIt Script To Exe Converter” . Do not forget to put a daw - "Console?" , So that the script can use the output in StdOut. You can also make your own icon.



The compiled code runs perfectly and works on the local machine, but how can we run it on all computers on the network? Come to the aid of the great and terrible Mark Russinovich with one of his PsExec utilities ( you can take it here ). She allows us, using a simple text list of computers, to run our softphone on each of them. But its main advantage is that only local administrator rights on a remote PC are required for its operation, and technical rights always have these rights.

The command to run this pipeline is
psexec.exe @ computerlist.txt -u domain \ tech_name -p password -c -f our_name.exe
computerlist.txt - file with a list of computers that will be accessed (must be in the working directory)
domain \ tech_name and password - the domain account of a technical support employee on whose behalf our exe's will be launched
name of our.exe is an AutoIt compiled script (must be in the working directory)

As a result, having banished such a script over the network, we will get a good overview of office computers, and most importantly, we will save a lot of nerve cells, both for technical support and for users.

PS We can take a list of computers on the network using the console command NET VIEW , at the output we will get the names of the computers on the network, all that remains is to select the ones we need and copy them to the list for PsExec

Source: https://habr.com/ru/post/149754/


All Articles