Jump to content
Kacper.Michta

Looking to retrieve all Location IDs [SOLVED]

Recommended Posts

Posted (edited)

Hi,

I am currently using a script provided by another user from the following link:

It seems to work perfectly fine when run against a single location, however I have a slight difference. Instead of running this script for a single location and producing an email/ticket from the results. I would like to run this across ALL location IDs and download the installers into a file structure that corresponds to  \\ClientName\LocationName\... structure.

I have already created the latter part of the script which creates the folders and populates them with the installers, however what I do need, is for it to run against all LocationID's. Is there some sort of SQL I am missing, or an export option somewhere within Automate, where I can retrieve a list of all current Location ID values? I have seen other users here use SQL queries for running scripts on each returned machine, but I have not seen any documentation or forums for returning/running something across all Locations. Is this possible?
 

SOLUTION:

Managed to find out how to find this info, I'm sure it's not the most efficient way of doing so, but I have no prior SQL knowledge. So here's my approach, I have a script running an "SQL Get Value" which returns the count of rows in the 'locations' table.

image.png.d508670c58581a67140088f5713c261a.png

I then set whatever the output of this is, to be the top limit for iterating through the locations. Using "SQL Get DataSet" I can grab all column values that I need from the `locations` table. I then iterate and use a counter variable to individually select rows from the DataSet using "SQL Fetch DataSet Row". The script then simply logs the location name along with its ID in the script log (for proof of concept):
image.png.3312507c017297a3a56cce1f27fd45ce.png

For now this will be an effective way to run a script on each LocationID value. I might try to get it to output a CSV for a more general use case in the future. Feel free to let me know if this can be improved/if you can spot any glaring mistakes.

Edited by Kacper.Michta

Share this post


Link to post
Share on other sites

Once a token is created, you can use that same token for all Clients & Locations by simply changing the LocationID in the Powershell when executed. Previously the MSI was hard coded with LocationID=1. Now with the token, it will embed the MSI with the selected LocationID when is was created with the script, although the Powershell will assign the LocationID upon execution. 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...