I am recieving the following errors- Unexpected token \'Get-Service\' in express
ID: 441160 • Letter: I
Question
I am recieving the following errors-
Unexpected token 'Get-Service' in expression or statement.
At line:16 char:30
Unexpected token 'Get-Process' in expression or statement.
At line:17 char:30
Unexpected token 'h:ist321systeminfo.ps1' in expression or statement.
At line:18 char:23
$title = "System Utilities"
$message = "Select which utility you would like to view."
$A = New-Object System.Management.Automation.Host.ChoiceDescription "&A", ` "Show Services."
$B = New-Object System.Management.Automation.Host.ChoiceDescription "&B", ` "Show Processes."
$C = New-Object System.Management.Automation.Host.ChoiceDescription "&C", ' "Displays systeminfo.ps1"
$options = [New-Object System.Management.Automation.Host.ChoiceDescription[]] ($A, $B, $C)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
switch ($result)
{
0 {"You selected A." Get-Service}
1 {"You selected B." Get-Process}
2 {"You selected C." h:ist321systeminfo.ps1}
}
Explanation / Answer
switch ($result) { 0 {"You selected A.", Get-Service} 1 {"You selected B.", Get-Process} 2 {"You selected C." , h:ist321systeminfo.ps1} }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.