1 | param([switch]$confirm)
|
---|
2 |
|
---|
3 | Function AskForConfirmation ($title_text, $message_text, $yes_text, $no_text)
|
---|
4 | {
|
---|
5 | if ($confirm) {
|
---|
6 | $title = $title_text
|
---|
7 | $message = $message_text
|
---|
8 |
|
---|
9 | $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", $yes_text
|
---|
10 |
|
---|
11 | $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", $no_text
|
---|
12 |
|
---|
13 | $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
|
---|
14 |
|
---|
15 | $result = $host.ui.PromptForChoice($title, $message, $options, 0)
|
---|
16 | } else {
|
---|
17 | $result = 0
|
---|
18 | }
|
---|
19 |
|
---|
20 | return $result
|
---|
21 | }
|
---|
22 |
|
---|
23 | pnputil -e | ForEach-Object { if ($_ -match "Published name :.*(oem\d+\.inf)") {$inf=$matches[1]} elseif ($_ -match "Driver package provider :.*Oracle") {$inf + " " + $_} }
|
---|
24 |
|
---|
25 | $result = AskForConfirmation "Clean up the driver store" `
|
---|
26 | "Do you want to delete all VirtualBox drivers from the driver store?" `
|
---|
27 | "Deletes all VirtualBox drivers from the driver store." `
|
---|
28 | "No modifications to the driver store will be made."
|
---|
29 |
|
---|
30 | switch ($result)
|
---|
31 | {
|
---|
32 | 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 } }
|
---|
33 | 1 {"Removal cancelled."}
|
---|
34 | }
|
---|