ndalmolin_13
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(-($Days Inactive))
$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.
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(-($Days
$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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to help :)
ASKER