Erwin Pombett
asked on
In the following function in powershell how can I write to console and write to the file $filename ?
Hello,
in the following function, how to use the redirection in order to write to the file - the file is created - $filename ?
my files are always empty.
here's my function
thanks in advance.
toshi
in the following function, how to use the redirection in order to write to the file - the file is created - $filename ?
my files are always empty.
here's my function
function Get_Tshr_WhatTestingMachineHasTester( [string[]]$arrayOfMachinesNames= $(Get_tshr_MachinesNames_OutOfDataFile_InArray) )
{
$filename = "testersOnMachines" + $(get-date -Format yyyy-MM-dd_HH_mm_ss)
$toto = New-Item -Path c:\temp\testersIE -name $filename -ItemType file
foreach($aHostName in $arrayOfMachinesNames)
{
$sw = [Diagnostics.Stopwatch]::StartNew()
if(Test-Connection $aHostName -Count 1 -Quiet) {
Get_Tshr_InfosOnTesterMachineUser($aHostName)
}
else{
Write-Host "host :" $aHostName " n'est pas atteignable"
}
$sw.Stop()
Write-Host "time-elapsed : " -NoNewline >> $toto
Write-Host $sw.Elapsed -ForegroundColor Cyan
}
}
thanks in advance.
toshi
I believe you have to use the Out-File commandlet as shown in the help screen snipet below for a output to a file. Have to go so could look at your code example specifically later, but maybe this gets you going.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot ,
your solution does write to the file.
toshi.
your solution does write to the file.
toshi.