@@ -1115,8 +1115,12 @@ function Confirm-SkillsInstallPlan {
11151115 return $false
11161116 }
11171117
1118- $answer = Read-Host ' 继续执行以上安装计划?输入 y 确认'
1119- return $answer -in @ (' y' , ' Y' , ' yes' , ' YES' )
1118+ $choices = [System.Management.Automation.Host.ChoiceDescription []]@ (
1119+ [System.Management.Automation.Host.ChoiceDescription ]::new(' &Yes' , ' 执行以上安装计划。' ),
1120+ [System.Management.Automation.Host.ChoiceDescription ]::new(' &No' , ' 取消安装计划。' )
1121+ )
1122+ $selected = $Host.UI.PromptForChoice (' 确认安装计划' , ' 继续执行以上安装计划?' , $choices , 1 )
1123+ return $selected -eq 0
11201124}
11211125
11221126function New-SkillsLogFile {
@@ -1237,6 +1241,7 @@ function Invoke-SkillsExternalCommand {
12371241 $process.WaitForExit ()
12381242 $stdout = $stdoutTask.GetAwaiter ().GetResult()
12391243 $stderr = $stderrTask.GetAwaiter ().GetResult()
1244+ $exitCode = $process.ExitCode
12401245 }
12411246 finally {
12421247 $process.Dispose ()
@@ -1251,15 +1256,15 @@ function Invoke-SkillsExternalCommand {
12511256 Write-SkillsLogLine - LogPath $LogPath - Message " STDERR $ ( $stderr.TrimEnd ()) "
12521257 }
12531258
1254- Write-SkillsLogLine - LogPath $LogPath - Message " EXIT $ ( $process .ExitCode ) "
1259+ Write-SkillsLogLine - LogPath $LogPath - Message " EXIT $exitCode "
12551260 $result = [pscustomobject ]@ {
1256- ExitCode = $process .ExitCode
1261+ ExitCode = $exitCode
12571262 StdOut = $stdout
12581263 StdErr = $stderr
12591264 }
12601265
1261- if ($process .ExitCode -ne 0 -and -not $AllowFailure ) {
1262- throw " 外部命令执行失败($ ( $process .ExitCode ) ): $commandLine "
1266+ if ($exitCode -ne 0 -and -not $AllowFailure ) {
1267+ throw " 外部命令执行失败($exitCode ): $commandLine "
12631268 }
12641269
12651270 return $result
0 commit comments