'How to turn List results into variables? (PowerShell)

I have what is probably a simple question.

My goal is to turn the results of the get-appvclientpackage cmdlet into a list from which I can take the product names and execute commands with each of the results as a different variable.

I have below my simple code:

    $installedpackages = get-appvclientpackage
    $displayedpackages = 
    $installedpackages | Format-List -property Name
    Foreach ($package in $displayedpackages)

That is about as far as I get. I can get it to display the list as I require but I need the results of the list to be assigned to variables that I can use to execute with strings later on in my full script.

Been through switch statements and I can get around the same result but never able to get the results assigned to variables. Any tips would be awesome!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source