Searching for an Environment Variable in a File

For a while now, when implementing Device Based Licensing using AppSense Application Manager, it has been easier to use a Scripted Rule to implement this. Using this method has one main benefit, you don’t need to redeploy a configuration every time you need to change a device name. During the early phases of implementations this could become quite tedious, it’s so much easier to update a text file.

Couple of caveats here: –

  1. Make sure that the text file secured correctly
  2. Make sure that the text file is in a location reachable by all machines

I’ve seen many of these scripts in circulation, some of which even seem to be based on old code that I’d written. All of the ones I’ve seen have been based on using a flat text file (one entry per line) to look up in. This is fine, but recently I was asked if this text file could actually be a CSV file. Once that request came in I decided it was about time that this type of script got a face lift and became PowerShell and a tiny bit more flexible. With that in mind, the script will work with a flat text file (one entry per line) or a CSV file.

Here it is…