Using Out-GridView -Wait but window closes anyway
Posted: 2021-Oct-28, 4:16 pm
My code does the following:
I'm initiating that script from the (Windows) command line like so:
Issue: Script runs find from ISE. But closes the Out-GridView GUI when run from a command line, even with -Wait.
What am I doin' wrong?
Code: Select all
Param(
[Parameter(Mandatory=$true)]
[string[]]
$find
)
Set-Location C:\script
Write-Output "Searching..."
$folders = @(a list of folders)
$excluded = @(a list of folders)
$results = foreach ($folder in $folders) {
Get-ChildItem $folder -Recurse -Exclude $excluded | Select-String -Pattern $find | select FileName, LineNumber, Path
}
$results | Out-GridView -Wait
I'm initiating that script from the (Windows) command line like so:
Code: Select all
powershell.exe -file C:\script\find.ps1 -find "something to fine"
What am I doin' wrong?