寻找PowerShell中相当于此命令的错误检查:
IF %ERRORLEVEL% NEQ 0
这是我正在尝试编写的PowerShell代码:
Write-Information "Installing .NET 3 from DVD:"
$NetFX3_Source = "D:\Sources\SxS"
dism /online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:$NetFX3_Source /NoRestart
IF (****TheCommandYouTellMe****) {
Write-Information "DVD not found, installing from online sources, the Win default method"
DISM.EXE /Online /Add-Capability /CapabilityName:NetFx3~~~~
Add-WindowsCapability –Online -Name NetFx3~~~~
}
$LASTEXITCODE
用于外部命令。 - Mathias R. Jessen