|
Break is not working ? $title = "Defrag Drive"
$message = "Select Drive letter to perform defragamention."
$cdrive = New-Object System.Management.Automation.Host.ChoiceDescription
"&C drive", "Analyse C:\ drive."
$ddrive = New-Object System.Management.Automation.Host.ChoiceDescription
"&D drive", "Analyse D:\ drive."
$quit = New-Object System.Management.Automation.Host.ChoiceDescription
"&Quit", "Quit this session."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($cdrive,
$ddrive,$quit)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
switch ($result)
{
0 {$cmdline = "cmd /c c:\windows\system32\defrag.exe c:\ -a >
c:\%computername%_defrag.txt"}
1 {$cmdline = "cmd /c c:\windows\system32\defrag.exe d:\ -a >
d:\%computername%_defrag.txt"}
2 {break}
}
$result
=====================
I select Q, and it suppose to quit session, but it did not ? Why ? |