I altered it slightly (left some comments in):
$a = @('*.bat', '*.txt')
$b = Get-ChildItem -Filter $a
# Try naming functions in the format 'Verb-Noun' as this will keep it consistent with existing PowerShell naming conventions
function Delete-Items
{
$title = "Delete Files"
$message = "Do you want to delete the files in the folder?"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Deletes all files in the folder."
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Don't delete the files in the folder."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $Host.UI.PromptForChoice($title, $message, $options, 0)
switch ($result)
{
0 { Write-Host "Hot Damn!" }
1 { Write-Host "Darn!" }
}
}
# 'if ($b)' can be misleading. I would only do this if $b were a Boolean
# 'if ($b.Length -gt 0)' is clearer as it is a better indication of what you mean
if ($b.Length -gt 0)
{
Delete-Items
}
else
{
Write-Host "Nope...Nothing there"
}
Other than that, seems fine.