Simplistic GUI for Powershell input
I ran into a simple example of how you can use out-gridview with the -OutputMode switch (like -Passthru). It creates a simplistic GUI for Powershell input.
- This script displays all servers in your domain and lets you select multiple.
- Then it provides you with a list of powershell scripts in c:\scripts and lets you choose one.
- At last it will run the script on those servers and presents the output in a gridview.
All kudos for Mike Robbins
1 2 3 4 5 6 7 8 9 |
Invoke-Command -ComputerName ( Get-ADComputer -Filter {OperatingSystem -like 'Windows Server*' -and enabled -eq $true} | Out-GridView -OutputMode Multiple -Title 'Select Servers to Query:' | Select-Object -ExpandProperty DNSHostName ) -FilePath ( Get-ChildItem -Path C:\Scripts\*.ps1 | Out-GridView --OutputMode Single -Title 'Select PowerShell Script to Run:' | Select-Object -ExpandProperty FullName ) | Out-GridView -Title 'Results' |