DEV Community

Cover image for PowerShell Core | Out-GridView 😎Welcome Back😎
Ewerton Jordão
Ewerton Jordão

Posted on

 

PowerShell Core | Out-GridView 😎Welcome Back😎

Out-GridView no PowerShell Core

E ae, pessoal, beleza ? Vamos falar sobre uma feature muito bacana para quem utiliza o PowerShell 5.1. Esse cmdlet está disponível por padrão, porém, se você utiliza o PowerShell Core 6.X provavelmente notou que ele não estava disponível, mas isso acabou 🥳🥳🥳.

O grid é bem útil na visualização do output de objetos, pois conseguimos aplicar filtros,e é uma ótima opção para usuários com pouca intimidade com scripts.

Vamos então aos passos necessários para utilizar o Out-GridView.

  1. Ter o PowerShell Core 6.2+ no seu SO. (disponível para Linux, Windows, macOS, everywhere)
  2. E o módulo Microsoft.PowerShell.GraphicalTools.

Obs: No script presumo que você já tenha o PowerShell Core no seu SO, e que a PSGallery esteja como provider trusted, ao instalar um módulo ele vai buscar em um repositório que neste caso é a PSGallery.

Get-PSRepository
Enter fullscreen mode Exit fullscreen mode

Output esperado após executar o cmdlet acima.

InstallationPolicy SourceLocation Name
Trusted https://www.powershellgallery.com/api/v2 PSGallery

Caso o Output do cmdlet seja conforme tabela abaixo:

InstallationPolicy SourceLocation Name
Untrusted https://www.powershellgallery.com/api/v2 PSGallery

Definimos o valor para Trusted desta maneira:

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted  
Enter fullscreen mode Exit fullscreen mode

Exemplo Windows 10:
Out-GridView em funcionamento no Windows 10

Exemplo centOS:
Out-GridView em funcionamento no centOS

Fico devendo o output no macOS :/, desculpe.

É isso pessoal, não se esqueça, PS é vida.

Curtiu? Quer saber mais?

GitHub logo PowerShell / GraphicalTools

Modules that mix PowerShell and GUIs/CUIs! - built on Avalonia and gui.cs

GraphicalTools

The GraphicalTools repo contains several different graphical-related PowerShell modules including:

  • Microsoft.PowerShell.GraphicalTools - A module that provides GUI experiences based on Avalonia.
  • Microsoft.PowerShell.ConsoleGuiTools - A module that provides console-based GUI experiences based on Terminal.Gui (gui.cs).

Installation

Microsoft.PowerShell.GraphicalTools

Install-Module Microsoft.PowerShell.GraphicalTools
Enter fullscreen mode Exit fullscreen mode

Microsoft.PowerShell.ConsoleGuiTools

Install-Module Microsoft.PowerShell.ConsoleGuiTools
Enter fullscreen mode Exit fullscreen mode

Features

Microsoft.PowerShell.GraphicalTools

Out-GridView documentation

Cross-Platform

Linux Windows Mac
linux-gif window-gif macos-gif
  • Out-Gridview
    • View and filter objects
    • Generate reusable filter code

Microsoft.PowerShell.ConsoleGuiTools

Out-ConsoleGridView documentation

screenshot of Out-ConsoleGridView

Cross-Platform

  • Out-ConsoleGridview
    • View and filter objects

Development

1. Install PowerShell 6.2+

Install PowerShell 6.2+ with these instructions.

3. Clone the GitHub repository:

git clone https://github.com/PowerShell/GraphicalTools.git
Enter fullscreen mode Exit fullscreen mode

4. Install Invoke-Build

Install-Module InvokeBuild -Scope CurrentUser
Enter fullscreen mode Exit fullscreen mode

Now you're ready to build the code. You can do so in one of two ways:

Building the code from PowerShell

PS C:\path\to\GraphicalTools> Invoke-Build Build
Enter fullscreen mode Exit fullscreen mode

Note: You can build a single module using the -ModuleName parameter:

Invoke-Build Build -ModuleName Microsoft.PowerShell.ConsoleGuiTools
Enter fullscreen mode Exit fullscreen mode

From there you can import…


Top comments (0)

The AI Brief

AI generated git commit messages

Minimize the struggle of remembering what you just coded. AI-generated commits make it easier to manage projects and keep track of changes. The Nutlope/aicommits project demonstrates how AI can improve commit messages.

I open sourced an AI that creates any UI in seconds

Make AI-generated user interfaces a breeze. This open-source project harnesses the power of generative AI technologies like chatGPT to create versatile, quick, and intuitive UI components.

Use AI to commit like a PRO in 1 second

Upgrade your commit message game with AI. Boost your productivity by using ChatGPT to generate commit messages and avoid context switching. OpenCommit is an open-source library that helps you achieve this easily.

Build your own ChatGPT starter kit

Train AI models on custom data for improved domain-specific knowledge. Combine the power of WebView technologies and this starter kit to train your ChatGPT model on specific websites, allowing for better-optimized outcomes.