O'Reilly logo

Learn PowerShell Toolmaking in a Month of Lunches by Don Jones and Jeffrey Hicks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

25.1. Using Out-GridView

We’ll start by using the Out-GridView cmdlet, which will be available on any computer that has the PowerShell ISE installed. We’ll make one minor change to our application’s OK button handler; the complete handler is listed here:

$OKButton_Click={
    if ($EventLogName.Visible) {
        # retrieve event log
        if ($EventLogName.SelectedIndex -gt -1) {
            $entries = Get-EventLog -Computer $ComputerName.Text `
                                    -Log $EventLogName.SelectedItem
            $entries | Out-GridView
        }
    } else {
        # populate event log list
        $logs = Get-EventLog -ComputerName $ComputerName.Text `
                             -List |
                Select-Object -ExpandProperty Log
        Load-ComboBox -ComboBox $EventLogName `
                      -Items $logs
        $EventLogName.Visible = $true
        $labelSelectEventLog.Visible = $true
    }
}

We’ve piped $entries ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required