modifying an existing script Inventory script

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.

$prop = @{
SiteID = "1"
ComputerName = $
Manufacturer = $ComputerInfo.Manufacturer
Model = $ComputerInfo.model
Productkey = $null
OS = $OSInfo.caption
ServicePacklevel = $Servicepack
Domain = $ComputerInfo.Domain
IP = $IPAddress
HDDSize = $HDrives
CPUSpeed = $
Ram = [string]([math]::Round($ComputerInfo.TotalPhysicalMemory / 1GB)) + " GB"
MACAddress = $MacAddress
SerialNumber = $BiosInfo.SerialNumber
ServiceTagNumber = $BiosInfo.SerialNumber
ExpressServiceTagNumber = $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.


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:

  1. Hard code the SiteID without the technicians going into the code itself.
  2. Create the service from the script via command line. Can this be done with a dotnet command/script?
  3. 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.


I found this documentation. I believe this might help.


does anyone have a working script for pulling inventory for domain computers, using text file for computers to scan and create .csv report?

Can the SiteID be $ENV:UserDomain so you dont have to hard code?

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)