PC inventory

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
Techpro
Posts: 2
Joined: Tue Jan 10, 2017 6:04 am

PC inventory

Post by Techpro »

Hello,
I have created a script that will prompt a technician for a SiteID number which will then populate an object with all of the computer specific information from the machine it is run on and then perform an invoke-RestMethod to our API with a JSON file which will then populate an inventory based on the 'SiteID' in the JSON file.

This script runs in a perpetual 'while' loop and reports to our inventory database every 4 hours.

I then take Powershell Studio and via the Script engine, create an executable which will install this script as a service. I take that executable and install it on the appropriate workstations. The service reports in with the specs of the machine to verify it is still online and communicating with our servers.

I want to make this tool available to other technicians to run on many client sites, but they will need to run a script that allows them to enter a SiteID and then from that input, create an executable that will run as a service. I would like to make one complete package that will prompt them for the ID and then create the EXE that when installed, will install as a service.

I know I can convert scripts to services via PowerShell Studio, but is it possible that I can create a script that a technician can run to prompt for a siteID and then from that, generate an EXE that when ran, will install as a service?

jvierra
Posts: 14691
Joined: Tue May 22, 2007 9:57 am
Answers: 7
Has voted: 2 times
Been upvoted: 5 times

Re: PC inventory

Post by jvierra »

For this task you should not use a service. Just schedule the script to run every 4 hours and test it at a command prompt until it works correctly. Be sure to run the service as an account that has access to all resou5rces required.
What you are doing is not why we use services. Services are intended for other purposes. Scheduled Tasks are the way we do this kind of thing in Windows.

User avatar
Techpro
Posts: 2
Joined: Tue Jan 10, 2017 6:04 am

Re: PC inventory

Post by Techpro »

I am okay with a scheduled task, however end game is that this will be a tool for technicians to use. It needs to be deploy able via GPO with the ability to make a custom field 'SiteID' for each customer.

Idea is to create a script that will create a custom EXE/MSI from a PowerShell Script that has the specific SiteID field, then deploy out to multiple workstations, either via invoking a PSSession for workgroups or GPO for a domain. Whether the end install is a service or just a scheduled task is fine. Services are easier to monitor and restart if they fail.

Would rather not have the technicians go into the code itself to modify SiteID, but have the tech run either a script, EXE or MSI file that prompts for the SiteID and then the end product can be deployed to multiple machines recursively or via GPO.

jvierra
Posts: 14691
Joined: Tue May 22, 2007 9:57 am
Answers: 7
Has voted: 2 times
Been upvoted: 5 times

Re: PC inventory

Post by jvierra »

That is what parameters are for.

A service will no make this any easier.

You can also use the machine name as the ID or use the AD Site definition.

Locked