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.
- Ter o PowerShell Core 6.2+ no seu SO. (disponível para Linux, Windows, macOS, everywhere)
- 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
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
Fico devendo o output no macOS :/, desculpe.
É isso pessoal, não se esqueça, PS é vida.
Curtiu? Quer saber mais?
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
Microsoft.PowerShell.ConsoleGuiTools
Install-Module Microsoft.PowerShell.ConsoleGuiTools
Features
Microsoft.PowerShell.GraphicalTools
Cross-Platform
- Out-Gridview
- View and filter objects
- Generate reusable filter code
Microsoft.PowerShell.ConsoleGuiTools
Out-ConsoleGridView documentation
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.git4. Install Invoke-Build
Install-Module InvokeBuild -Scope CurrentUserNow 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 BuildNote: You can build a single module using the -ModuleName parameter:
Invoke-Build Build -ModuleName Microsoft.PowerShell.ConsoleGuiToolsFrom there you can import…
Top comments (0)