Author Posts

December 18, 2017 at 4:38 am

Good evening all!

I have a database and two functions.

In the database, I have a table that holds all log entries from PS scripts I run and tie in logging. Typically, that table's record will have an entry like this:

TimeStamp | ScriptName | Action | Result | Notes | System (for computer touched by the script).

I have a function created that will list for me all scripts listed in that table that have run in the last month. It's basically called, "FUNCTION List-LoggedScripts". If I run this script, I'll get a result like:


Those results, above, are the scripts, again, that have been run in the last month.

I have a second function that will allow me to pull the logs from the last run of a script. This script is called "Get-LatestLogs". It's structured something like this:

FUNCTION Get-LatestLogs ($scriptName){



Instead of typing in a $scriptName answer explicitly, I'll like to be able to pikc from the results of the first function List-LoggedScripts at the time that I run the command, seeing the options from a drop down when I type:

Get-LatestLogs -scriptName DROPDOWNHERE

I have Googled to no avail. I see where you can add an array, but not create an array from a function and add it on the fly.

Possible? Help?

Thanks for anything ya'll can offer.


December 18, 2017 at 6:51 am

If I understand your scenario correctly, Out-Gridview -PassThru might be what you're looking for. This will let you choose the scripts from your first function and send it out.

Consider the small example below:

function ProcessDropDown($process) {

    Write-Warning "You chose process: $($process.Name)"

ProcessDropDown(Get-Process | Out-GridView -PassThru)

Running that code and choosing the Powershell process will give you the following output:

WARNING: You chose process: powershell

December 18, 2017 at 11:45 am

Mark, you didn't find what you're looking for because you didn't know what it's called. It's called 'Dynamic Parameter'.
Here's a script that shows about how to do this, and I'm sure that now you know what to google for you'll find a lot more info online. Please post your progress..

December 19, 2017 at 2:43 pm

This is what I was looking for. Took me a quick minute to figure out how to implement according to my needs but it's up and running as needed now. Thank you!