Organising data in a CSV file to present in a drop-down menu

Hey guys,

Long time lurker, now I have an issue of my own. I know this will start to sound like an SCCM issue, but it’s a PowerShell command I need to run to assist with the SCCM stuff.

Project

I run an in-house SCCM server and I am trying to get an N-Able agent automatically installed during a task sequence. The issue is that the agent needs the customer/site ID in the install command in order to correctly report back to the right area. So far I’ve come across the how-to guides on

  • Pausing a task sequence to have the PXE operator choose a particular customer/site from N-Able,
  • How to have a script run during the paused task sequence (such as a user-interaction GUI),
  • How to query the N-Able API to output all customer/sites to a .csv file (which includes the customer/site ID in a separate column)
  • How to create the script to create a drop-down menu in a GUI from a PowerShell script and set the selection to a variable that can be called later, retrieving the customer/sites from a particular column in the .csv and using them as the items in the drop-down menu – which will be used at the paused task sequence.

Issue

The .csv file is set out in the following format:

ID Customer_Site ParentID
1 ExampleCustomer
2 ExampleSite 1
3 ExampleCustomer2

and so on and so forth.

Currently, the script to populate the list in the drop-down menu is using the Customer_Site column, but I need to somehow have the two columns (ID + Customer_Site) related in order to have ExampleSite selected, and have the variable set to ‘2’.

Bonus points would be to assist with how to format the drop-down menu so that it shows the Customer_Site objects without a ‘ParentID’ in bold, with the corresponding child site’s show in plain text below the ParentID site, (This is because the ID field is populated in sequential order, and ID 45 might be a new site for the Customer at ID 1 but was created later on) like the following:

ExampleCustomer

ExampleSite

ExampleCustomer2

If I can get these done, I will definitely shout a beer or two with some crypto to any and all that help.

I am using the GetCustomerListwithSites-Prompted.ps1 script from here – (customized so that it’s not prompted, and just has credentials set in variables)

I am using this script for the creation of the GUI with a dropdown menu

Any assistance would be greatly appreciated!!

submitted by /u/Kroucher
[link] [comments]

Leave a Reply