I'm trying to redirect the script output to a txt but it fails
Clear-Host
$Elementos =Get-WmiObject Win32_Battery -namespace 'root\CIMV2'
foreach ($Elemento in $Elementos) {
$Elemento.BatteryStatus
$Elemento.EstimatedChargeRemaining
$Elemento.EstimatedRunTime} >C:\temp\Prueba.txt
the result of the script is correct
2
100
71582788
And the resulting error is:
"The term '>' is not recognized as the name of a cmdlet, function, script file or executable program. Check if you typed the name correctly, or if a path included, verify that the path is correct and try again. Published 7 Character: 2 +> <<<< C: \ temp \ Test.txt + CategoryInfo: ObjectNotFound: (>: String) [], CommandNotFoundException + FullyQualifiedErrorId: CommandNotFoundException"
I can't need to say that the path is correct.
If I run for instance:
PowerShell (Get-WmiObject win32_battery).estimatedChargeRemaining > C:\temp\Prueba.txt
that run's OK
Any idea what I'm doing wrong?
Thanks in advance.
Kind Regards.
Emilio Sancha MS Access MVP 2006-2011