Add-Type -AssemblyName System.Windows.Forms # Create form $form = New-Object System.Windows.Forms.Form $form.Text = 'File Search' $form.Size = New-Object System.Drawing.Size(500,300) # Adjust form size here $form.StartPosition = 'CenterScreen' # Create label $label = New-Object System.Windows.Forms.Label $label.Location = New-Object System.Drawing.Point(10,20) $label.Size = New-Object System.Drawing.Size(480,20) # Adjust label size here $label.Text = 'Enter your search query:' $form.Controls.Add($label) # Create textbox $textBox = New-Object System.Windows.Forms.TextBox $textBox.Location = New-Object System.Drawing.Point(10,40) $textBox.Size = New-Object System.Drawing.Size(460,20) # Adjust textbox size here $form.Controls.Add($textBox) # Create button $button = New-Object System.Windows.Forms.Button $button.Location = New-Object System.Drawing.Point(10,70) $button.Size = New-Object System.Drawing.Size(75,23) $button.Text = 'Search' $button.Add_Click({ $query = $textBox.Text $drives = @{ 'H' = 'Hugh'; 'I' = 'Charlie'; 'K' = 'Kirk'; 'S' = 'Spock'; 'T' = 'Tom'; 'U' = 'Jerry'; 'Z' = 'Beta' } $outputBox.Text = '' foreach ($drive in $drives.Keys) { if (Test-Path "$drive`:\") { Get-ChildItem -Path "$drive`:\" -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "*$query*" } | ForEach-Object { $outputBox.Text += "`n$($_.Name) located on $($drives[$drive]) ($drive`:)" } } } }) $form.Controls.Add($button) # Create output box $outputBox = New-Object System.Windows.Forms.TextBox $outputBox.Location = New-Object System.Drawing.Point(10,100) $outputBox.Size = New-Object System.Drawing.Size(460,160) # Adjust output box size here $outputBox.Multiline = $true $outputBox.ScrollBars = 'Vertical' $form.Controls.Add($outputBox) # Show form $form.ShowDialog()