【发布时间】:2015-11-09 19:33:26
【问题描述】:
我正在尝试将脚本输出重定向到 txt,但它失败了
Clear-Host
$Elementos =Get-WmiObject Win32_Battery -namespace 'root\CIMV2'
foreach ($Elemento in $Elementos) {
$Elemento.BatteryStatus
$Elemento.EstimatedChargeRemaining
$Elemento.EstimatedRunTime} >C:\temp\Prueba.txt
脚本的结果是正确的
2
100
71582788
由此产生的错误是:
"术语 '>' 未被识别为 cmdlet、函数的名称, 脚本文件或可执行程序。检查您是否输入了名称 正确,或者如果包含路径,请验证路径是否正确,并且 再试一次。已发表 7 字符:2 +> : String) [], CommandNotFoundException + FullyQualifiedErrorId: CommandNotFoundException"
我不用说路径是正确的。
例如,如果我跑步:
PowerShell (Get-WmiObject win32_battery).estimatedChargeRemaining > C:\temp\Prueba.txt
运行正常
知道我做错了什么吗?
提前致谢。
亲切的问候。
埃米利奥·桑查 MS Access MVP 2006-2011
【问题讨论】:
标签: powershell