$features = Start-Process powershell -Verb runAs -ArgumentList "Get-WindowsOptionalFeature –Online" $features
如何将结果返回到我的$feature变量中?
发布于 2017-07-07 05:35:33
快速解决方法:可以使用临时clixml文件存储Get-WindowsOptionalFeature cmdlet的结果:
$tempFile = [System.IO.Path]::GetTempFileName()
try
{
Start-Process powershell -Wait -Verb runAs -ArgumentList "-Command Get-WindowsOptionalFeature -Online | Export-Clixml -Path $tempFile"
$features = Import-Clixml -Path $tempFile
# Use $features
}
finally
{
if (Test-Path $tempFile)
{
Remove-Item -Path $tempFile -Force -ErrorAction Ignore
}
}https://stackoverflow.com/questions/44953882
复制相似问题