Inventory script

Welcome Forums General PowerShell Q&A Inventory script

Viewing 1 reply thread
  • Author
    Posts
    • #252020
      Participant
      Topics: 68
      Replies: 72
      Points: 543
      Rank: Major Contributor

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

      }</p>
      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:

      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.

       

    • #252041
      Participant
      Topics: 68
      Replies: 72
      Points: 543
      Rank: Major Contributor
Viewing 1 reply thread
  • You must be logged in to reply to this topic.