ISHRemote/PowerShell - Best way to iterate through publication versions?

I'd like to create a PowerShell script that iterates through all the versions in a publication before performing the core tasks in the script. Roughly speaking, the logic tree I'd like to script goes something like this:

1. Find all publications
2. For each publication, find all publication versions
3. For each publication version, test if a metadata field 'X' is populated
4. If field X is populated:
- Loop through our supported languages to see if output 'Y' is created for that language. If not, create it.
- Publish output Y. **Special case for EN - DON'T publish EN output if the value of field X is equal to (the value of field X for the next publication version)

Note, I *probably* can assume that there will be an EN pub output for each version. This means there's probably a way to achieve what I want, via Find-IshPublicationOutput - however, at first glance it seems like the logic will be a lot more complex. Especially with regard to the special case above.

Can anyone provide some high-level advice about the best/simplest way to achieve the script logic I want, via ISHRemote?

thanks,
Charlie