Link to home
Start Free TrialLog in
Avatar of ndalmolin_13
ndalmolin_13Flag for United States of America

asked on

Getting Powershell Output to a File

Hello Experts,

I have a Powershell script that displays the output I want on the screen, but I'm not sure how to send it to a text or csv file as well.  I'm sure it is an easy thing to do, I'm just drawing a blank.  Here is my code:

$DaysInactive = 90
$Time = (Get-Date).Adddays(-($DaysInactive))
$DeadComputers = Get-ADComputer -Filter {LastLogonTimeStamp -lt $time} -Properties LastLogonTimeStamp | select name
foreach ($i in $DeadComputers)
{
if (Test-Connection -ComputerName $i.name -BufferSize 16 -Count 1 -Quiet) {Write-Host $i.name is online}
else {Write-Host $i.name is offline}
}

Thanks in advanced for your help.
SOLUTION
Avatar of Dustin Saunders
Dustin Saunders
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ndalmolin_13

ASKER

Thanks