Welcome › Forums › General PowerShell Q&A › modifying an existing script Inventory script
- This topic has 4 replies, 4 voices, and was last updated 3 months, 1 week ago by
Participant.
-
AuthorPosts
-
-
August 23, 2020 at 5:38 pm #252020
I am reaching out to look for ideas on how to customize a an existing PowerShell so the technicians can easily create and install either via on a single workstation or on a domain.
The script uses basic ‘Get-wmiobject’ cmdlets and gathers PC information. It will then create a custom object and then convert the output to a json file format and upload to our database via API. The SiteID indicates which client this computer belongs to.
PowerShell12345678910111213141516171819$prop = @{SiteID = "1"ComputerName = $ComputerInfo.nameManufacturer = $ComputerInfo.ManufacturerModel = $ComputerInfo.modelProductkey = $nullOS = $OSInfo.captionServicePacklevel = $ServicepackDomain = $ComputerInfo.DomainIP = $IPAddressHDDSize = $HDrivesCPUSpeed = $CPUInfo.nameRam = [string]([math]::Round($ComputerInfo.TotalPhysicalMemory / 1GB)) + " GB"MACAddress = $MacAddressSerialNumber = $BiosInfo.SerialNumberServiceTagNumber = $BiosInfo.SerialNumberExpressServiceTagNumber = $ExpressServiceTag}My script will do a continual loop and once every 4 hours, run again and upload its data, which will reset a time field in our database which indicates when a machine ‘reported in’ last.
Using PowerShell Studio, I converted my script with the hard set ‘SiteID’ to a service and installed it on few workstations at a small client office and it works. The SiteID field will be custom for each site and I need to make this easy for technicians to install on workstations which some may still be running on PSversion 2 (Windows 7).
This is my ideal scenario for what this would look for as the process a technician would follow to create the executalbe to deploy to one of our clients. The technician would just have to supply the SiteID number.
Create-InventoryEXE – SiteID 10 -Name “BobsAutoInv”
The output is an EXE or MSI that can be run on a workstation or set to run as a GPO to run on an entire Domain.
“BobAutoInv.msi”
I am not committed to the idea that this HAS TO BE A SERVICE and to run this as a scheduled task. My thought is that services might be more easily monitored by our auditor where we can run a report on services running to see if this one is stopped, started, or even there.
Wonder if anyone can give me general direction on how to:
- Hard code the SiteID without the technicians going into the code itself.
- Create the service from the script via command line. Can this be done with a dotnet command/script?
- If a service is not a good idea, how to do this as a scheduled task, keeping in mind that older version of PowerShell might have to be contended with.
Not looking for a line by line explanation. I can do the learning and the research, but just point me in the direction of what I need to be looking at to accomplish this.
-
This topic was modified 3 months, 1 week ago by
kvprasoon. Reason: code formating and title change
-
August 23, 2020 at 9:07 pm #252041
I found this documentation. I believe this might help.
-
October 8, 2020 at 10:07 am #261764
does anyone have a working script for pulling inventory for domain computers, using text file for computers to scan and create .csv report?
-
October 8, 2020 at 2:44 pm #261908
Can the SiteID be $ENV:UserDomain so you dont have to hard code?
-
October 8, 2020 at 4:40 pm #261920
There are many Computer inventory scripts available in galleries and blogs. Have you searched for “powershell computer inventory script” ? I have about 834,000 results (0.48 seconds)
-
-
AuthorPosts
- The topic ‘modifying an existing script Inventory script’ is closed to new replies.