2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsyncparam([switch]$confirm)
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsyncFunction AskForConfirmation ($title_text, $message_text, $yes_text, $no_text)
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync if ($confirm) {
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync $title = $title_text
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync $message = $message_text
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", $yes_text
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", $no_text
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync $result = $host.ui.PromptForChoice($title, $message, $options, 0)
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync $result = 0
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync return $result
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsyncpnputil -e | ForEach-Object { if ($_ -match "Published name :.*(oem\d+\.inf)") {$inf=$matches[1]} elseif ($_ -match "Driver package provider :.*Oracle") {$inf + " " + $_} }
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync$result = AskForConfirmation "Clean up the driver store" `
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync "Do you want to delete all VirtualBox drivers from the driver store?" `
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync "Deletes all VirtualBox drivers from the driver store." `
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync "No modifications to the driver store will be made."
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsyncswitch ($result)
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync 0 {pnputil -e | ForEach-Object { if ($_ -match "Published name :.*(oem\d+\.inf)") {$inf=$matches[1]} elseif ($_ -match "Driver package provider :.*Oracle") {$inf} } | ForEach-Object { pnputil -d $inf } }
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync 1 {"Removal cancelled."}